static
来源:互联网 发布:a1530支持什么网络 编辑:程序博客网 时间:2024/06/06 00:20
能够独立于类的所有对象进行使用的成员
可以在创建类的任何对象之前访问该成员
本质上是全局变量
声明为静态的方法有几个限制:
- 它们只能直接调用其他静态方法
- 它们只能直接访问静态数据
- 它们不能以任何方式引用this或super关键字
可以声明静态代码块:
// Demonstrate static variables, methods, and blocks.
class UseStatic {
static int a = 3;
static int b;
static void meth(int x) {
System.out.println("x = " + x);
System.out.println("a = " + a);
System.out.println("b = " + b);
}
static {
System.out.println("Static block initialized.");
b = a * 4;
}
public static void main(String args[]) {
meth(42);
}
}
0 0
- static
- static
- static{}
- static
- static
- Static
- static
- static
- Static
- static
- static
- static
- static
- static
- static
- static
- static
- static
- Android studio安装常见错误之Gradle sync failed: Cause: org/gradle/api/...
- Android Studio编译运行找不到指定APK的问题
- window.top.location.href 和 window.location.href 的区别
- 机器视觉之 ICP算法和RANSAC算法
- 使用Google Earth画线路图
- static
- Android 如何在Eclipse中查看Android API源码以及support包源码
- js字符串与对象互转函数
- Linux中修改时间
- ActiveMq发送接收对象
- 实战录 | 新年第一弹 说说SNMP两大核心
- mysql group by,left join
- myeclipse2014 blue 及破解
- Leetcode-25 Reverse Nodes in k-Group