📜  Java与C#

📅  最后修改于: 2021-05-29 18:25:32             🧑  作者: Mango

C#是一种通用的,现代且面向对象的编程语言,发音为“ C Sharp”。它是由Anders Hejlsberg及其团队领导的Microsoft开发的。

Java是通用的,并行的,基于类,面向对象等的通用计算机编程语言Java应用程序通常被编译为可在任何Java虚拟机(JVM)上运行的字节码,而与计算机的体系结构无关。

以下是C#和Java之间的一些主要区别:

Feature C# Java
Operator Overloading C# supports operator overloading for multiple operators. Java does not support operator overloading.
Runtime Environment C# supports CLR(Common Language Runtime). Java supports JVM(Java Virtual Machine).
API Control C# API are controlled by open source community. Java API are also controlled by open community process.
Public Classes In 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 Exceptions C# does not supports for checked exception. In some cases checked exceptions are very useful for smooth execution of program. Java supports both checked and unchecked exceptions.
Platform Dependency C# 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.
Pointers In C# pointers can be used only in unsafe mode. Java does not supports anyway use of pointers.
Conditional Compilation C# supports for conditional compilation. Java does not supports for conditional compilation.
goto statement C# supports for goto statement. Java does not supports for goto statement. Use of goto statement will cause error in Java code.
Structure and Union C# supports structures and unions. Java doesn’t support structures and unions.
Floating Point C# does not supports strictfp keyword that means it result of floating point numbers may not be guaranteed to be same across all platforms. Java supports strictfp keyword that means its result for floating point numbers will be same for various platform.