Java中的关键字有哪些?
1)48个关键字:abstract、assert、boolean、break、byte、case、catch、char、class、continue、default、do、double、else、enum、extends、final、finally、float、for、if、implements、import、int、interface、instanceof、long、native、new、package、private、protected、public、return、short、static、strictfp、super、switch、synchronized、this、throw、throws、transient、try、void、volatile、while。
2)2个保留字(现在没用以后可能用到作为关键字):goto、const。
3)3个特殊直接量:true、false、null。
byte 字节型 8bit
char 字符型 16bit
boolean 布尔型
short 短整型 16bit
int 整型 32bit
float 浮点型 32bit
long 长整型 64bit
double 双精度 64bit
void 无返回
public void A(){} 其他需要返回的经常与return连用
null 空值
true 真
false 假
static 静态的
属性和方法都可以用static修饰,直接使用类名.属性和方法名。 只有内部类可以使用static关键字修饰,调用直接使用类名.内部类类名进行调用。 static可以独立存在。静态块
final 最终的不可被改变的
方法和类都可以用final来修饰 ,final修饰的类是不能被继承的 ,final修饰的方法是不能被子类重写。
常量的定义:
final修饰的属性就是常量。
super 调用父类的方法
常见public void paint(Graphics g){
super.paint(g); ··· }
this 当前类的父类的对象
调用当前类中的方法(表示调用这个方法的对象)
this.addActionListener(al):等等
1259

被折叠的 条评论
为什么被折叠?



