Tyster 17 Light Poster

NOTE: The classes I posted above are NOT complete, but I think they have what you are looking for.

Cheers!

Tyster

Tyster 17 Light Poster

I have something that might help... When you have an array list of objects, each object has instance variable values. The idea is to extract and print the values of each variable in each object. The way you are doing it now prints the OBJECT (and its memory address, I think), rather than the variable values.

To solve this have a look at the program below. It's a program that sets and gets student grades, names, and student Id's and each student object is stored in an Array List. I wrote it to do exactly what you want (I think!). You need 2 classes... the main() method class to provide values for the variables, and a second class that has Getter methods, where each get() method gets the value you want. You print the values using the get() methods.

Here's the main() class...

public class GradeTester {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		ArrayList<Grader> GraderList = new ArrayList<Grader>();
		
		Scanner in = new Scanner(System.in);
		
		System.out.println("Enter the number of students: ");
		String numStudents = in.next(); // Store the number of students
		int numStu = Integer.valueOf(numStudents); //Convert String to int
		
		System.out.println("Enter the Assignment name: ");
		String assignName = in.next(); // Store the assignment name
		
		for(int i = 0; i < numStu; i++){
					
			System.out.println("Enter the student name: ");
			String studentName = in.next(); // Store the student name
					
			System.out.println("Enter the student ID: ");
			String studentID = in.next(); // Store the student ID
						
			System.out.println("Enter the student score: "); …