Reputation: 737
public void display(detailTom tomData)
{
ArrayList<detailTom> temp = new ArrayList<detailTom>();
for (int i=0;i<tomData.toString().length();i++)
{
temp=tomData[i];
System.out.println(temp.getMark1());
}
}
Hello all,
I am trying to iterate through an arraylist tomData which is an object arraylist. I am trying to iterate through the list and display the variable of the object "Mark1".
The error is get is "Array required but detailTom found"
any ideas? Or any other way of iterating through tomData?
Upvotes: 0
Views: 111
Reputation: 3822
What you've provided doesn't really make sense, but based on the comments I'm guessing the answer you're looking for is something like the following:
public void display(List<DetailTom> tomData) {
for (DetailTom detail : tomData) {
System.out.println(detail.getMk1());
}
}
I've renamed your class from detailTom
to DetailTom
as is the convention in Java:
Names of class types should be descriptive nouns or noun phrases, not overly long, in mixed case with the first letter of each word capitalized.
Upvotes: 1