Data types | Java | C# |
---|---|---|
Single-root (unified) type system | No | Yes |
Signed integers | Yes; 8, 16, 32, 64 bits | Yes; 8, 16, 32, 64 bits |
Unsigned integers | No | Yes; 8, 16, 32, 64 bits |
Character | Yes | Yes |
Date/time | Yes; reference type | Yes; value type |
IEEE 754 binary32 floating point number | Yes | Yes |
IEEE 754 binary64 floating point number | Yes | Yes |
High precision floating point number | No; but see Arbitrary size decimals | 128-bit (28 digits) Decimal type |
Boolean type | Yes | Yes |
Strings | Immutable reference type, Unicode | Immutable reference type, Unicode |
Arbitrary size integers | Reference type; no operators | Yes |
Arbitrary size decimals | Reference type; no operators | No |
Complex numbers | No | Yes |
Reference types | Yes | Yes |
Arrays | Yes | Yes |
Value types | No; only primitive types | Yes |
Enumerated types | Yes; reference type | Yes; scalar |
Lifted (nullable) types | No; but wrapper types | Yes |
Tuples | No | Yes |
Pointers | No | Yes |
Reference types | Java | C# |
Garbage collection | Yes | Yes |
Weak references | Yes | Yes |
Soft references | Yes | No |
Proxy support | Yes; proxy generation | Yes; object contexts |
Object initialization | Bottom-up (fields and constructors) | Top-down (fields); bottom-up (constructors) |
Object orientation | Java | C# |
Classes | Yes | Yes |
Interfaces | Yes | Yes |
Abstract classes | Yes | Yes |
Member accessibility levels | Public, package, private, protected | Public, protected, internal, protected internal, private |
Class level inner classes | Yes | Yes |
Instance level inner classes | Yes | No |
Partial classes | No | Yes |
Deprecation/obsolescence | Yes | Yes |
Overload versioning | Some | Yes |
Properties | No | Yes |
Events | No | Yes |
Operators (operator overloading) | No | Yes |
Indexers | No | Yes |
Implicit conversions | No | Yes |
Explicit conversions | No | Yes |
Fields and initialization | Java | C# |
Fields | Yes | Yes |
Constants | Yes | Yes |
Static (class) constructors | Yes | Yes |
Instance constructors | Yes | Yes |
Finalizers/destructors | Yes | Yes |
Instance initializers | Yes | No |
Hierarchy initialization | Top-bottom, lexical order | Top-bottom-top, lexical order |
Object initializers | No | Yes |
Collection initializers | No; can be modelled | Yes |
Array initializers | Yes | Yes |
Methods and properties | Java | C# |
Virtual | Virtual by default | Non-virtual by default |
Abstract | Yes | Yes |
Sealing | Yes | Yes |
Explicit interface implementation | No | Yes |
Value (input) parameters | Yes | Yes |
Reference (input/output) parameters | No | Yes |
Output (output) parameters | No | Yes |
Variadic methods | Yes | Yes |
Optional arguments | No | Yes |
Named arguments | No | Yes |
Generator methods | No | Yes |
Extension methods | No | Yes |
Conditional methods | No | Yes |
Partial methods | No | Yes |
Generics | Java | C# |
Reified generics | No | Yes |
Co-variance | Yes | Yes |
Contra-variance | Yes | Yes |
Reference type constraint | Yes; implicit | Yes |
Value/primitive type constraint | No | Yes |
Constructor constraint | No | Yes |
Relation constraint | Yes | Yes |
Primitive/value type support | No | Yes |
Migration compatibility | Yes | No |
Functional programming | Java | C# |
Delegates/method references | No | Yes |
Closures/lambdas | No; some use cases covered by anonymous inner classes | Yes |
Expression trees | No | Yes |
Query expressions | No | Yes |
Runtime (dynamic) binding | Java | C# |
Late-bound (dynamic) type | No | Yes |
Runtime type information and manipulation | Java | C# |
Runtime type information | Yes; but with type erasure | Yes |
Runtime generics realization | No | Yes |
Runtime type construction | No; third party tools exist | Yes |
Statements | Java | C# |
Loops | Yes | Yes |
Conditionals | Yes | Yes |
Flow control | Yes | Yes |
Assignment | Yes | Yes |
Exception control | Yes | Yes |
Variable declaration | Yes | Yes |
Variable type inference | No | Yes |
Deterministic disposal (ARM-blocks) | No | Yes |
Expressions and operators | Java | C# |
Arithmetic operators | Yes | Yes |
Logical operators | Yes | Yes |
Bitwise logic operators | Yes | Yes |
Conditional | Yes | Yes |
String concatenation | Yes | Yes |
Casts | Yes | Yes |
Boxing | Yes; implicit | Yes; implicit |
Unboxing | Yes; implicit | Yes; explicit |
Lifted operators | No | Yes |
Overflow control | No | Yes |
Strict floating point evaluation | Yes; opt-in/out | No |
Local classes | Yes | No |
Ad-hoc (anonymous) classes | No | Yes |
Verbatim (here-)strings | No | Yes |
Exceptions | Java | C# |
Checked exceptions | Yes | No |
Try-catch-finally | Yes | Yes |
Arrays and collections | Java | C# |
One-dimensional, zero-based index arrays | Yes | Yes |
Rectangular (multidimensional) arrays | No | Yes |
Jagged (arrays of arrays) arrays | Yes | Yes |
Non-zero based arrays | No | Some |
Unified arrays and collections | No | Yes |
Maps/dictionaries | Yes | Yes |
Sets | Yes | Yes |
Lists/vectors | Yes | Yes |
Maps | Yes | Yes |
Queues/stacks | Yes | Yes |
Bags/multisets | Yes | Yes |
Metadata | Java | C# |
Metadata annotations/attributes | Interface based | Class based |
Positional arguments | No; unless a single argument | Yes |
Named arguments | Yes | Yes |
Default values | At definition | Through initialization |
Nested types | Yes | Yes |
Specialization | No | Yes |
Conditional metadata | No | Yes |
Preprocessing, compilation and packaging | Java | C# |
Namespaces | Packages | Namespaces |
Packaging | Package | Assembly |
File contents | Restricted | Free |
Conditional compilation | No | Yes |
Custom errors/warnings | No | Yes |
Explicit regions | No | Yes |
Threading and synchronization | Java | C# |
Native interoperability | Java | C# |
External/native methods | Yes | Yes |
Marshalling | External glue code required | Yes; metadata controlled |
Pointers and arithmetics | No | Yes |
Native types | No | Yes |
Fixed size buffers | No | Yes |
Explicit stack allocation | No | Yes |
Address pinning (fixing) | No | Yes |
Address-of | No | Yes |
Object pinning (fix variable to address) | No | Yes |
Source:wikipedia |