Java引用
package yingyong;
public class yingyong {
public static class person{ //static需要特别引起注意,不能去掉!!!!!
public int age;
public int height;
public void show()
{
System.out.println("我的年龄是:"+age+","+"我的身高是:"+height);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
person[] student;
student=new person[2];
person lee=new person();
lee.age=22;
lee.height=178;
person zhang=new person();
zhang.age=18;
zhang.height=185;
student[0]=zhang;
student[1]=lee;
for(int i=0;i<2;i++)
{
student[i].show();
}
}
}
结果如下
注意如果去掉static,会出现