Table B.1 shows the closest matching C# equivalents to the 49 Java keywords.
Java keyword | Closest C# equivalent | Comments |
---|---|---|
abstract | abstract | |
assert [3] | - | Use the Debug.Assert static method in C# instead |
boolean | bool | |
break | break | |
byte | sbyte | An sbyte is a signed 8-bit numeric simple type, while byte is an unsigned 8-bit numeric simple type in C# – Java's primitive types are all signed |
case | case | |
catch | catch | |
char | char | |
class | class | |
const* | const | This keyword is reserved in Java, but not used – in C#, const is used to declare a constant |
continue | continue | |
default | default | |
do | do | |
double | double | |
else | else | |
extends | - | In C#, : is used to denote class inheritance instead of using the extends keyword |
native | extern | |
final | const/readonly | Java final variables are similar to C# constants and read-only variables, though there are differences between the latter two |
finally | finally | |
float | float | |
for | for | |
goto [1] | goto | Java's goto keyword has no functionality although it is reserved – C#'s goto keyword can be used to 'jump' to a labeled statement |
if | if | |
implements | - | In C#, : is used to denote interface implementation instead of using the implements keyword |
import | using | |
instanceof | is | |
int | int | |
interface | interface | |
long | long | |
native | extern | |
new | new | |
package | namespace | |
private | private | |
protected | protected | |
public | public | |
return | return | |
short | short | |
static | static | |
strictfp [2] | - | |
super | base | |
switch | switch | |
synchronized | lock | |
this | this | |
throw | throw | |
throws | - | All exceptions in C# are unchecked – unchecked exceptions are automatically propagated backwards to the calling method if not handled without the need to specify the throws clause in the method prototype |
transient | - | |
try | try | |
void | void | |
volatile | volatile | |
while | while |
[3] added into the Java language in Java 2 SDK 1.4
[1] reserved but not used in Java
[2] added into the Java language in Java 2
18.223.206.225