statictest.java

来自「java 教程源码」· Java 代码 · 共 27 行

JAVA
27
字号
//c4:StaticTest.java
//author:ZhangHongbin 
//This program is protected by copyright laws.
//Static Test.  
class Mankind
{
	static int sex;
}
public class StaticTest extends Mankind
{
	
	public static void main(String[] args)
	{
		Mankind somePerson=new Mankind();//创建对象
		Mankind anotherPerson=new Mankind();
		System.out.println("0.somePerson.sex="+somePerson.sex);
		System.out.println("0.anotherPerson.sex="+anotherPerson.sex);
		somePerson.sex=100;//给对象中的数据赋值
		System.out.println("1.somePerson.sex="+somePerson.sex);
		System.out.println("1.anotherPerson.sex="+anotherPerson.sex);
		anotherPerson.sex=200;
		System.out.println("2.somePerson.sex="+somePerson.sex);
		System.out.println("2.anotherPerson.sex="+anotherPerson.sex);

	}
} 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?