标签:[] com new t windows test 技术 努力 logs int
版本参数:jdk-7u72-windows-i586
注意事项:博文内容仅供参考,不可用于其他用途。
代码
class Test{
static String country = "China";
//static 成员变量,被这个类的所有对象共享
}
class Demo{
public static void main(String[] args){
Test t1 = new Test();
Test t2 = new Test();
//t1/t2的country都是China
System.out.println(t1.country);
System.out.println(t2.country);
//其中的一个对象改变其country,其他对象再用时,也被改变
t1.country = "USA";
System.out.println(t1.country);
System.out.println(t2.country);
}
}
编译与运行

——————————————————————————————————————————
Java优秀,值得努力学习。
学习资源:黑马程序员_Java基础视频-深入浅出精华版/*来自黑马云课堂,网上可以找到*/
如果您觉得博文内容有可以优化的地方,请留下评论,我会认真思考的。
JavaSE7基础 static 成员变量,被这个类的所有对象共享
标签:[] com new t windows test 技术 努力 logs int
原文地址:http://www.cnblogs.com/jizuiku/p/7136399.html