The Wayback Machine - https://web.archive.org/web/20240311121546/https://www.geeksforgeeks.org/java-vs-c-sharp/
Open In App
Related Articles

Java vs C#

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

C# is a general-purpose, modern and object-oriented programming language pronounced as “C sharp”. It was developed by Microsoft led by Anders Hejlsberg and his team. 

Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented etc. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture. 

Below are some major differences between C# and Java: platform-independent APIs

FeatureC#Java
Operator OverloadingC# supports operator overloading for multiple operators.Java does not support operator overloading.
Runtime EnvironmentC# supports CLR(Common Language Runtime).Java supports JVM(Java Virtual Machine).
API ControlC# API are controlled by open source community.Java API are also controlled by open community processes support.
Public ClassesIn C#, there can be many public classes inside a source code.In Java there can be only one public class inside a source code otherwise there will be compilation error.
Checked ExceptionsC# does not support Unix-based checked exceptions. In some cases checked exceptions are very useful for the smooth execution of the program.Java supports both checked and unchecked exceptions.
Platform DependencyC# is cross-platform and runs on both Windows & Unix based systems.Java is a robust and platform independent language. Platform independency of Java is through JVM.
PointersIn C# pointers can be used only in unsafe mode.Java does not support anyway use of pointers.
Conditional CompilationC# supports for conditional compilation.Java does not supportconditional compilation.
goto statementC# supports for goto statement.Java does not supportsupport for goto statement. The use of goto statement will cause errors in Java code.
Structure and UnionC# supports structures and unions.Java doesn’t support structures and unions.
Floating PointC# does not supports strictfp keyword which means it result of floating point numbers may not be guaranteed to be the same across all platforms.Java supports strictfp keyword which means its result for floating point numbers will be the same for various platforms.
LanguageC# is based on JavaScript.It is in itself is an independent language.
RoutingFor routing configuration, it uses ASP.NetFor routing configuration, it uses akka.routing
Dependency InjectionIt uses dependency injection.It not only uses dependency injection but also allows modification.
SpeedSpeed is slower than JAVA.Speed is faster than the speed of C#.
PolymorphismIt supports polymorphism by default.It supports polymorphism by default.
DelegatesIt contains delegates.It does not contain delegates.

Last Updated : 26 Apr, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials