| | |
Looping through an Array
![]() |
•
•
Join Date: May 2007
Posts: 11
Reputation:
Solved Threads: 0
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?
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?
•
•
Join Date: Apr 2007
Posts: 126
Reputation:
Solved Threads: 6
you can do something like the following
Java Syntax (Toggle Plain Text)
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) }
Last edited by new_2_java; May 2nd, 2007 at 7:36 pm.
![]() |
Similar Threads
- Safe Array (C++)
- C++ Performance Tips (C++)
- C++ file to array (C++)
- Order of precedence (C)
- Dynamically write selectedIndex to a <dl> element (JavaScript / DHTML / AJAX)
- Desiging a set of rules for a match (C++)
- Arrays Assignment!!! (C++)
Other Threads in the Java Forum
- Previous Thread: error checking
- Next Thread: [maxFileSize] and [maxBackupIndex]
| Thread Tools | Search this Thread |
-xlint add android api applet application applications array arrays automation bank bi binary blackberry bluetooth chat class client code compile compiler component database development digit eclipse equation error event fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image infinite input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying pearl problem program programming project qt recursion scanner screen scrollbar server set sms sort sorting spamblocker sql sqlserver string superclass swing system text-file thread threads tree variablebinding windows xor





