static关键字

static关键字

1.修饰属性,方法,还可以单独使用必须由实例化对象来调用

2.static 修饰的方法和属性可由类名直接调用,而非static修饰的方法和属性
class Student{
static String color="黄色";
float height=1.70f;
foat weight=70f;

public static study(){
System.out.println("我爱学习");

}
void sleep(){

System.out.println("学生擅长睡觉");
}
class Main{

posted @ 2018-08-11 07:47  *Struggle  阅读(159)  评论(0)    收藏  举报