Home > Back-end >  How to do to satisfy multiple conditions at the same time and output? Do not use the database query
How to do to satisfy multiple conditions at the same time and output? Do not use the database query

Time:01-20

I am novice, not understand place, please forgive me if there is any expression
Have a student class, the students have six attributes, respectively: student number (id), name (name), gender (sex), age (age), grade (grade), class (classNo). After the initialization, input the 10 students information, now want to query student information, such as input "name=zhang SAN", the relevant information of the zhang SAN is printed, if the input name=zhang SAN, sex="f" is for the women's name for zhang SAN and sex related information is output... If the input output after six conditions to meet the six, want to ask you how great god do

Private static void setStudent (int id, String name, char sex, int the age, int grade, int classNo) {
Student student=new Student();
Student. SetId (id);
Student. Elegantly-named setName (name);
Student. SetSex (sex);
Student. SetAge (age);
Student. SetGrade (grade);
Student. SetClassNo (classNo);
Students. The add (student);
}
Private static void init () {
SetStudent (1, "zhang", "f", 14,3,1);
SetStudent (2, "liaoning province", "f", 13,3,1);
SetStudent (3, "Shanghai", "f", 13,3,1);
SetStudent (4, "Beijing", "m", 12,3,1);
SetStudent (5, "guangzhou", "f", 13,3,1);
SetStudent (6, "dalian", "m", 11,4,2);
SetStudent (7, "shenzhen", "f", 11,4,2);
SetStudent (8, "hangzhou", 'm', 12,4,2);
SetStudent (9, "Qingdao", "f", 12,4,2);
SetStudent (10, "Harbin", "m", 13,4,2);
}
Private static void out Student (Student) {

System. The out. Print (" NO: "+ student. GetId () +" ");
System. The out. Print (" name: "+ student. GetName () +" ");
System. The out. Print (" gender: "+ student. GetSex () +" ");
System. The out. Print (" age: "+ student. GetAge () +" ");
Grade System. Out. Print (" : "+ student. GetGrade () +" ");
System. The out. Print (" class: "+ student. GetClassNo () +" ");
System.out.println();
}
  • Related