import java.util.ArrayList;
Import the Java. Util. Iterator;
Public class Test {
Public static void main (String [] args) {
Student s1=new Student (" 2016001 ", "zhang", "male", 21).
Student s2=new Student (" 2016002 ", "li si", "male", 22).
List
List. Add (s1);
List. The add (s2);
Iterator
//judge whether there is any element
While (____________ hold) {
Student s=it. Next ();
String sno=s.g etSno ();
String name=s.g etName ();
String sex=s.g etSex ();
Int the age=s.g etAge ();
System. The out. Println (sno + "" + name +" "+ +" "+ age sex);
}
}
On the horizontal line to fill what?
CodePudding user response:
import java.util.ArrayList;Import the Java. Util. Iterator;
Public class Test {
Public static void main (String [] args) {
Student s1=new Student (" 2016001 ", "zhang", "male", 21).
Student s2=new Student (" 2016002 ", "li si", "male", 22).
List
List. Add (s1);
List. The add (s2);
Iterator
//judge whether there is any element
While ( it. HasNext () {
)Student s=it. Next ();
String sno=s.g etSno ();
String name=s.g etName ();
String sex=s.g etSex ();
Int the age=s.g etAge ();
System. The out. Println (sno + "" + name +" "+ +" "+ age sex);
}
}
CodePudding user response:
List. The iterator ();It. HasNext ()
This question for baidu, post is too time consuming