Sometimes, it's useful to cut through the crap. Highlighted is the basic
Java 8 data, in some cases, also the pre-Java 8 construct.
First, list traversal...
Anonymous innerclasses...
Second example of innerclass...
Sorting collections...
Using lambda expressions and streams...
public class Person
{
private String firstName, lastName, job, gender;
private int salary, age;
public Person( String firstName, String lastName, String job, String gender, int age, int salary )
{
this.firstName = firstName;
this.lastName = lastName;
this.gender = gender;
this.age = age;
this.job = job;
this.salary = salary;
}
...
}
// later code constructing lists:
List< Person > javaProgrammers = new ArrayList<>()
{
{
add( new Person( "Elsdon", "Jacob", "Java programmer", "male", 43, 2000 ) );
add( new Person( "Tamsen", "Brittany", "Java programmer", "female", 23, 1500 ) );
add( new Person( "Floyd", "Donny", "Java programmer", "male", 33, 1800 ) );
add( new Person( "Cindy", "Jonie", "Java programmer", "female", 32, 1600 ) );
add( new Person( "Vere", "Hervey", "Java programmer", "male", 22, 1200 ) );
add( new Person( "Maude", "Jaimie", "Java programmer", "female", 27, 1900 ) );
add( new Person( "Shawn", "Randall", "Java programmer", "male", 30, 2300 ) );
add( new Person( "Jayden", "Corrina", "Java programmer", "female", 35, 1700 ) );
add( new Person( "Palmer", "Dene", "Java programmer", "male", 33, 2000 ) );
add( new Person( "Addison", "Pam", "Java programmer", "female", 34, 1300 ) );
}
};
List< Person > phpProgrammers = new ArrayList<>()
{
{
add( new Person( "Jarrod", "Pace", "PHP programmer", "male", 34, 1550 ) );
add( new Person( "Clarette", "Cicely", "PHP programmer", "female", 23, 1200 ) );
add( new Person( "Victor", "Channing", "PHP programmer", "male", 32, 1600 ) );
add( new Person( "Tori", "Sheryl", "PHP programmer", "female", 21, 1000 ) );
add( new Person( "Osborne", "Shad", "PHP programmer", "male", 32, 1100 ) );
add( new Person( "Rosalind", "Layla", "PHP programmer", "female", 25, 1300 ) );
add( new Person( "Fraser", "Hewie", "PHP programmer", "male", 36, 1100 ) );
add( new Person( "Quinn", "Tamara", "PHP programmer", "female", 21, 1000 ) );
add( new Person( "Alvin", "Lance", "PHP programmer", "male", 38, 1600 ) );
add( new Person( "Yvonne", "Shari", "PHP programmer", "female", 40, 1800 ) );
}
};
And now, iterate those lists...