Java语言关键字关键字/保留字
abstract
extends
multicast
boolean
false
native
break
final
new
byte
finally
null
byvalue
float
operator
case
for
outer
cast
future
package
catch
generic
private
char
goto
protected
class
if
public
const
implements
rest
continue
import
return
default
inner
short
delegate
instanceof
static
do
int
super
double
interface
switch synchronized
else
long
this
throw
throws
transient
true
try
var
void
volatile
while
对于上面列出的关键字/保留字有以下几点说明:
这里列出的是不能(或不应该)用作标识符的名字,因此比Java1.1语言所使用的保留字更多一些。
保留字delegate和multicast是Visual J++ 6.0新增的。它们定义在Windows基类(WFC)中,用来帮助处理事件。
Visual J++ 6.0把const和goto认作保留字(即它们以其他颜色显示)但在Java1.1中,它们并无特殊含义。不过由于Visual J++ 把它们认作保留字,就不能把它们用作标识符。
保留字byvalue, cast, future, generic, inner, operator, outer, rest和var在Java语言中也是保留字,但在Java1.1中也并无特殊含义,不过VisualJ++并不将它们标记为格式颜色。Visual J++ 允许将这些字用作标识符。但是,为了尽可能增加程序的可移植性,让程序清楚明了,最好不要这样做。
从技术的角度而言,布尔值true和false并不是保留字,但不能将它们用作标识符,因此,它们看起来、用起来和给人的感觉都像是保留字。
内部类型
类型 值 缺省值
----------------------------------------------------------------------
Boolean true和false false
Byte 从-128到128之间的整数值 0
Char 从/u0000到/uFFFF之间的双字节编码字符 /u0000
Double 64位浮点数 0.0
Float 32位浮点数 0.0
Int 32位整数 0
Long 64位整数 0
Short 16位整数 0
Java格式概述 下面对于Java语言格式的简要概述提供了对该语言常用语法结构的快速参考,而并不是对于Java语言完整正式的语法说明。流程控制do while循环(相关关键字:break和continue)do{loop body} while (boolean expression )for循环(相关关键字:break和continue)for ( initialization; boolean expression; increment ){loop body}if(相关关键字:else) if (boolean expression){statement ( s )}else{statement ( s )}switch(相关关键字:break, case和default)switch ( integral variable ){case integral value: statements ( s) break;other case (s ) as necessarydefault; statements (s )}try 块(相关关键字:catch, finally, throw和throws)try { statement ( s )}catch (exceptionType identifier ) { statement ( s )}other catch blocks as necessaryfinally{statement ( s )}while循环(相关关键字:break和continue) while ( boolean expression ) { statement ( s ) }类方括弧表示可选格式[public][abstract] class ClassName{methods and member varibles}继承class SubclassName [extends SuperclassName] [implements InterfaceName]{methods and member varibles}接口[public][abstract] interface InterfaceName [extends SuperInterfaceName]{methods declarations and final member varibles}软件包package packageName;import packageName.className;import packageName.*;方法Access方法[accessModifier] returnType methodName ( parameter_list ){body of method}其中,accessModifier可以是public, private, protected或缺省(package)。线程synchronized returnType methodName ( parameter_list ) {...}继承[final | abstract ] returnType methodName ( parameter_list ) {...}returnType methodName ( parameter_list ) {...}{super (parameter_list );statements ( s );return value;}类方法static returnType methodName ( parameter_list ){statement ( s )}native方法class className{ native returnType methodName ( parameter_list ); static { native method initialization ( s ) } remainder of class definitions}异常returnType methodName ( parameter_list ) throws exceptionName{ statement ( s ) throw new exceptionName; statement ( s )}成员变量访问[ accessModifier ] type variableName [ = initialValue ]其中,accessModifier可以是public, private, protected或缺省(package)。行为staticfinalvolatiletransientTypecasting, RTTI (Run-Time Type Information, 运行期间类型信息)if (variable instanceof type ){ ((type ) variable ).method ( parameterList);statement( s )}