#4 – How is C# Different From Java?

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

Advertisements

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

6 Responses to #4 – How is C# Different From Java?

  1. Anup Verma says:

    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

  2. msuworld says:

    I don’t know java, so can’t differentiate 😦

  3. kai zhou says:

    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?

  4. proxy666666 says:

    In Java SE 7 and later, String object can be used in a switch statement’s expression.

  5. Svaria Lover says:

    In Java all methods are virtual by default. In C# you must be explicit.

  6. Mehraj Malik says:

    Java also allow(jdk 7 and above) String in switch statements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: