Appendix B. Comparing Java and C# keywords

Table B.1 shows the closest matching C# equivalents to the 49 Java keywords.

Table B.1. C# equivalents to Java keywords
Java keywordClosest C# equivalentComments
abstractabstract 
assert [3]-Use the Debug.Assert static method in C# instead
booleanbool 
breakbreak 
bytesbyteAn 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
casecase 
catchcatch 
charchar 
classclass 
const*constThis keyword is reserved in Java, but not used – in C#, const is used to declare a constant
continuecontinue 
defaultdefault 
dodo 
doubledouble 
elseelse 
extends-In C#, : is used to denote class inheritance instead of using the extends keyword
nativeextern 
finalconst/readonlyJava final variables are similar to C# constants and read-only variables, though there are differences between the latter two
finallyfinally 
floatfloat 
forfor 
goto [1]gotoJava's goto keyword has no functionality although it is reserved – C#'s goto keyword can be used to 'jump' to a labeled statement
ifif 
implements-In C#, : is used to denote interface implementation instead of using the implements keyword
importusing 
instanceofis 
intint 
interfaceinterface 
longlong 
nativeextern 
newnew 
packagenamespace 
privateprivate 
protectedprotected 
publicpublic 
returnreturn 
shortshort 
staticstatic 
strictfp [2]- 
superbase 
switchswitch 
synchronizedlock 
thisthis 
throwthrow 
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- 
trytry 
voidvoid 
volatilevolatile 
whilewhile 

[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

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.139.16