修改static中成员变量的值
2016-06-13 18:55
232 查看
class person{
String name;
int age;
static String country;
public person(){}
public person(String name,int age){
this.name=name;
this.age=age;
}
public person(String name,int age,String country){
this.name=name;
this.age=age;
this.country=country;
}
public void show(){
System.out.println("姓名是: "+name+" 年龄 "+age+" 国家 "+country);
}
}
class persontest{
public static void main(String [] args){
person p1=new person("大致",11,"中国");
p1.show();
person p2=new person("小明",11);
p2.show();
person p3=new person("小刚",11);
p3.show();
p3.country="美国";
p1.show();
p2.show();
p3.show();
}
}
class person{
String name;
int age;
static String country;
public person(){}
public person(String name,int age){
this.name=name;
this.age=age;
}
public person(String name,int age,String country){
this.name=name;
this.age=age;
this.country=country;
}
public void show(){
System.out.println("姓名是: "+name+" 年龄 "+age+" 国家 "+country);
}
}
class persontest{
public static void main(String [] args){
person p1=new person("大致",11,"中国");
p1.show();
person p2=new person("小明",11);
p2.show();
person p3=new person("小刚",11);
p3.show();
p3.country="美国";
p1.show();
p2.show();
p3.show();
}
}
相关文章推荐
- [翻译] Virtual method interception 虚方法拦截
- 函数中局部变量的返回
- shell脚本下的双 [ [ ] ]和单[ ]的联系和区别
- Android本地数据库查询电话号码归属地规则
- Network in Network - ICLR 2014
- document.referrer 特性
- golang学习之闭包
- JVM 类的加载初始化
- 32位与64位
- node-webkit:开发桌面+WEB混合型应用的神器
- base 和this的区别
- jdk环境搭建
- KEIL下S3C2440裸机开发
- 就C语言的指针、链表的原理和各类操作撰写一篇技术博客,说说自己学习C语言指针和链表的体会
- CodeIgniter学习笔记 Item2--CI中的MVC
- atoi()和atof()函数
- poi操作ppt创建表格
- spring中表单提交问题 400
- UIWindow
- CSS---div一行显示,超出以省略号代替