ArrayList manipulation and Comparators
Hi! I posted here yesterday (http://forum.java.sun.com/thread.jspa?threadID=5167975) and have since made some progress with my problem and encountered some new ones.
I'm really really new to this, and I'm sorry if it's frustrating to see newbies asking question after question. I'm reading in data about people from a .txt file and turning it into Strings and Integers:
publicstaticvoid main (String[] args)
{
ArrayList<Person> personList =new ArrayList<Person>();
People peopleDetails =new People();
people =new File("people.txt");
try{
input =new BufferedReader(new FileReader(people) );
while (( inputLine = input.readLine()) !=null){
StringTokenizer st =new StringTokenizer(inputLine);
//This will only work provided that each line only has 4 tokens
inputFirstName= st.nextToken();
inputSurname= st.nextToken();
inputDay = Integer.parseInt(st.nextToken());;
inputMonth= Integer.parseInt(st.nextToken());
// Creating a new person
newPerson =new Person(inputFirstName, inputSurname, inputDay, inputMonth);
System.out.println(inputFirstName +" " + inputSurname +"'s birthday is on the " + inputDay +
" day of the " + inputMonth +" month.");
System.out.println("*************");
System.out.println(" ");
// Adding the person to the ArrayList of people
personList.add(newPerson);
}
}
catch (FileNotFoundException ex){
System.out.println("File not found");
}
catch (IOException ex){
System.out.println("IO exception");
}
The output looks like this:
Michael Bluth's birthday is on the 14 day of the 6 month
****************
Lucille Bluth's birthday is on the 31 day of the 3 month
****************
etc, which is fine for now because I know I'm at least processing the file. When I try to print the contents of the ArrayList using
System.out.println(personList);
all I get is "[Person@51127a, Person@94257f, Person@29c58e, Person@691dee, Person@12bf892, Person@1cc5069, Person@b32ed4, Person@1c7980c, Person@cf710e]". Can anybody help me figure out why?
I'm also having no luck whatsoever sorting and printing the list of people in order of their birthdays, is there anybody that can help? Thanks so much.

