Hello,

I have the following line that prints a year and the matching fruit consumption; however I have 35 elements in each array that this line is got from.

I need help creating a loop that will parse rhe arrays and return the figure for each year.
//Display for one year. Needs a loop to run through ArrayList
System.out.println("Year: " + yearLabel.get(0) +" "+ berryData.get(0) + " "+ orangeData.get(0) +" "+ tangerineData.get(0)+"\n\n");

Can someone please push me in the right direction?

you can do something like the following

loop for (max-number of years)
{
      print (first year:)
      String val1 = your function(find matching year, if true return berry value)
      print (berry value);
      String val2 = same function(find matching year if true return tangerine value)
      print (tangerin value)
      and so on.....
      print (new line)
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.