JAVA学习day25--引用类型数组

引用类型数组

package day18;
//引用类型数组的演示
public class RefArrayDemo {

	public static void main(String[] args) {
		Student [] stus = new Student[3];
		stus[0] = new Student("zhangsan",25,"LF");
		stus[1] = new Student("lisi",25,"jms");
		stus[2] = new Student("wangwu ",28,"sd");
		System.out.println(stus[1].age);//25
		stus[2].sayHi();
		
		Student[] ss = new Student[]{
				new Student("zhangsan",25,"LF"),
				new Student("lisi",25,"jms"),
				new Student("wangwu ",28,"sd")
		};

	}

}

运行结果如下
JAVA学习day25--引用类型数组

上一篇:实验2


下一篇:实验二