Berikut adalah perbedaan kata kunci yang digunakan di C# dan Java untuk tujuan atau maksud yang sama.
C# Keyword | Java Keyword | Notes | C# Example | Java Example |
---|---|---|---|---|
Base | super |
Prefix operator that references the closest base class when used inside of a class’s method or property accessor. Used to call a super’s constructor or other method. |
|
Public MyClass(String s)
|
Bool | boolean | Primitive type which can hold either true or false value but not both. | bool |
boolean |
Is | instanceof | Boolean binary operator that accepts an l-value of an expression and an r-value of the fully qualified name of a type. Returns true iff l-value is castable to r-value. | MyClass myClass = new MyClass();
|
MyClass myClass = new MyClass();
|
lock | synchronized | Defines a mutex-type statement that locks an expression (usually an object) at the beginning of the statement block, and releases it at the end. (In Java, it is also used as an instance or static method modifier, which signals to the compiler that the instance or shared class mutex should be locked at function entrance and released at function exit, respectively.) | MyClass myClass = new MyClass();
|
MyClass myClass = new MyClass();
|
namespace | package | Create scope to avoid name collisions, group like classes, and so on. | namespace
|
//package must be first keyword in class file
|
readonly | const | Identifier modifier allowing only read access on an identifier variable after creation and initialization. An attempt to modify a variable afterwards will generate a compile-time error. | //legal initialization
|
//legal initialization
|
sealed | final | Used as a class modifier, meaning that the class cannot be subclassed. In Java, a method can also be declared final, which means that a subclass cannot override the behavior. | //legal definition
|
//legal definition
|
using | import | Both used for including other libraries into a project. | using |
import |
internal | private | Used as a class modifier to limit the class’s use inside the current library. If another library imports this library and then attempts to create an instance or use this class, a compile-time error will occur. | namespace Hidden
|
package Hidden;
|
: | extends | Operator or modifier in a class definition that implies that this class is a subclass of a comma-delimited list of classes (and interfaces in C#) to the right. The meaning in C# is very similar to C++. | //A is a subclass of
|
//A is a subclass of
|
: | implements | Operator or modifier in a class definition that implies that this class implements a comma-delimited list of interfaces (and classes in C#) to the right. The meaning in C# is very similar to C++. | //A implements I
|
//A implements I
|
Sumber : https://msdn.microsoft.com/en-us/library/ms836794.aspx#tchcjavakeywordcomparison