Hey Guys I'm really stuck on a question here what I'm supposed to do is
Write a class that represents a person. A person should have a name and an age.
Write a Java program that implements a linked list using the LinkedList class:
The program should create five people objects with different names and ages and
add them to the LinkedList using the add(e) method.
The program should then print out the names and ages of each person object in the
LinkedList, using a method or methods from the LinkedList class.
My problem is I have create five people objects with different names and ages andimport java.util.*; public class Linkedlist{ /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String[] firstName = {"John", "Paul", "George", "Ringo", "Pete"}; List<String> list1 = new LinkedList<String>(); for (String x : firstName) list1.add(x); printMe(list1); } //printMe Method private static void printMe(List<String> l){ for(String b :l) System.out.printf("%s ", b); System.out.println(); } }
add them to the LinkedList using the add(e) method. The program should then print out the names and ages of each person object in the
LinkedList, using a method or methods from the LinkedList class.
I'm not sure exactly how I'm able to do this. Does this explain my problem?
can anyone help me?
GROT