static静态关键词
概念
- static的特性:唯一性
- static静态关键词可以修饰代码中的所有成员。
要点
- 属性:static修饰类或者接口的属性时,该属性只属于该类或接口。该属性可以直接通过类名或者接口名直接调用,但是其唯一性体现在所有对象所使用的该属性都是同一份。
class Manage{
static x;
public static void main(String[] args){
Manage m1 = new Manage ();
m1.x=10;
Manage m2 = new Manage ();
m2.x=100;
Manage m3 = new Manage ();
m3.x=1000;
System.out.println (m1.x+