java 面向对象 --static
package charpter5.Demo09;
//static
public class Student {
private static int age; //静态的变量
private double score; //非静态的变量
public static void main(String[] args) {
Student s1 = new Student();
System.out.println(s1.age);
System.out.println(Student.age);
System.out.println(s1.score);
// System.out.println(Student.score); 不可调用
}
}
静态导入包
package charpter5.Demo09;标签:java,--,System,static,Student,println,out From: https://www.cnblogs.com/ssl-study/p/16734237.html
//静态导入包
import static java.lang.Math.random;
public class Static {
public static void main(String[] args) {
System.out.println(random());
}
}