Looping through an Array

Reply

Join Date: May 2007
Posts: 11
Reputation: JavaNewbie07 is an unknown quantity at this point 
Solved Threads: 0
JavaNewbie07 JavaNewbie07 is offline Offline
Newbie Poster

Looping through an Array

 
0
  #1
May 2nd, 2007
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?
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 126
Reputation: new_2_java is an unknown quantity at this point 
Solved Threads: 6
new_2_java new_2_java is offline Offline
Junior Poster

Re: Looping through an Array

 
0
  #2
May 2nd, 2007
you can do something like the following
  1. loop for (max-number of years)
  2. {
  3. print (first year:)
  4. String val1 = your function(find matching year, if true return berry value)
  5. print (berry value);
  6. String val2 = same function(find matching year if true return tangerine value)
  7. print (tangerin value)
  8. and so on.....
  9. print (new line)
  10. }
Last edited by new_2_java; May 2nd, 2007 at 7:36 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC