Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 553 Bytes

File metadata and controls

19 lines (14 loc) · 553 Bytes

Static 关键字

  • 静态方法
  • 静态变量
  • 静态类

定义一个方法为static,那就是说,无需本类的对象即可调用此方法

声明为static的方法有以下几条限制:

  1. 它们仅能调用其他的 static 方法
  2. 它们只能访问 static 数据
  3. 它们不能以任何方式引用 this 或 super

声明为 static 的变量实质上就是全局变量. (+ final 就是全局量) . 当声明一个对象时, 并不产生static变量的拷贝, 而是该类所有的实例变量共用同一个static变量.