#4 – How is C# Different From Java?
June 21, 2010 6 Comments
C# and Java are both object-oriented languages that derive their syntax from C and run in a managed environment. There are, however a number of differences. Here are the main ones:
- Syntactic differences, e.g. “class B extends A” instead of “class B : A”
- Java doesn’t use namespaces
- C# lock statement vs. Java synchronized statement
- C# has a few more access modifiers than Java
- In Java, enumerated types are full-fledged classes
- C# allows strings in switch statements
- C# programs make use of the .NET Framework; Java programs use the Java SE
Lots more at: C# From a Java Developer’s Perspective
Unlike Java, in C#:
1. datatype decimal is present and there are more integer data types
2. in switch: “break” is compulsory in all “cases” of the switch (with some exceptions)
3. operator overloading is supported
4. default access is private
5. Unsigned Right Shift(>>>) Bitwise operator NOT present
6. Implicitly typed variables can be used
I don’t know java, so can’t differentiate 😦
It has been a long time since I used Java last time, about 4 years ago. Don’t know how is Java developing looks like today, still J2EE, Struts, Hibernate, Spring? or Android?
In Java SE 7 and later, String object can be used in a switch statement’s expression.
In Java all methods are virtual by default. In C# you must be explicit.
Java also allow(jdk 7 and above) String in switch statements