| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
|
I have successfully created and exercised a user-defined
class “Person” with 9
private data fields and 18 public methods (9 gets and 9 puts).
I now want to store multi-occurrences of this class in an
ArrayList. The ArraryList is
defined as:
ArrayList
<Person> personArrayList = new ArrayList<Person>();
I have successfully loaded the instantiation of the class
into the ArrayList with the following statement:
personArrayList.add(newPerson);
Using the NetBeans debugger I was able to confirm that the
data does exist in ArrayList element zero (0). However, when I try to extract a data element from the class
with a the following statement:
System.out.println
(personArrayList.get(0).getFirstName());
I get the “cannot find symbol” error during compile.
The following statement:
System.out.println
("Value for personArrayList.get(0) = " + personArrayList.get(0));
Returns “Value
for personArrayList.get(0) = datainputdemo.Person@25d06e”
The datainputdemo
is the class where the ArrayList is declared and initialized.
When working directly with the class data structure the
following statement works fine:
System.out.println
(newPerson.getFirstName());
I am trying to point to an existing element in the ArrayList
and use a method in that object to extract and print the contents of a specific
data field. I am using Java 1.5.
Thanks in advance.
Joe Broghamer
|
_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.