Iam new in java and i have a Java Person class and i have created a List of Persons and i am able to print the list but i donot want to print the minimum and maximum age in a person list my code is
public class Person {
static String name;
static String lname;
static double age;
Person(String name,string lname,double age) {
Person.name = name;
Person.lname= lname;
Person.age = age;
}
}
//Main method
public void testQuestionInput() {
List<Person> persons = new ArrayList<Person>();
persons.add(new Person("Foo", "scientist",5));
persons.add(new Person("Foo", "scientist",4));
persons.add(new Person("Foo", "teacher",10));
persons.add(new Person("Bar", "student",11));
persons.add(new Person("Foo", "scientist",12));
for (Person person : _persons ) {
System.out.print(person);
}
}
I am able to print the list but i want to print a list in which i have to skip the maximum and minimum age in my case i want to print list without
"Foo", "scientist",4 and "Foo", "scientist",12
Thanks help would be appreciated.
staticmodifier of your instance variables.