package com.guoyasoft;
public class Student {
public String name;
public int age;
public Student next;
}
package com.guoyasoft;
public class Test {
public static void main(String[] args) {
Student a1=new Student();
a1.name="n1";
a1.age=1;
Student a2=new Student();
a2.name="n2";
a2.age=2;
a1.next=a2;
Student a3=new Student();
a3.name="n3";
a3.age=3;
a2.next=a3;
Student a4=new Student();
a4.name="n4";
a4.age=4;
a3.next=a4;
Student a5=new Student();
a5.name="n5";
a5.age=5;
a4.next=a5;
Student a=a1;
boolean flag=true;
while(flag){
System.out.println("name="+a.name+",age="+a.age);
a=a.next;
if(a==null){
flag=false;
}
}
// System.out.println("a1.name="+a1.name);
// System.out.println("a2.name="+a2.name);
// System.out.println("a3.name="+a3.name);
// System.out.println("a4.name="+a4.name);
}
}