944,133 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 5245
  • Java RSS
May 2nd, 2007
0

Looping through an Array

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
JavaNewbie07 is offline Offline
11 posts
since May 2007
May 2nd, 2007
0

Re: Looping through an Array

you can do something like the following
Java Syntax (Toggle Plain Text)
  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.
Reputation Points: 7
Solved Threads: 6
Junior Poster
new_2_java is offline Offline
127 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: error checking
Next Thread in Java Forum Timeline: [maxFileSize] and [maxBackupIndex]





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC