|
I'm not exactly sure about that, but i have a suggestion. if you want it to go through the array as a loop (e.g. array with 10 ints, 1 through ten in seperate array places - yourArray[0] would be 1, yourArray[1] would be 2, etc.) after the array is initialized, you use the enhanced for statement,
for ( int item : yourArray) {
System.out.println("Currently at " + item);
}
by the way, the ( int item : yourArray ) must be written exactly that, except your array name, not yourArray. I'm not sure if you can change the name item.. you could always experiment, but i doubt it.
this will go through each array item and is convention and reccomended for easier code reading. i'm not quite sure what is happening when you are getting an entire array from user input, but if u wanted to use an array to loop, thats how. using the word item in the loop block will return the value of the array item that the loop is currently using for the current iteration.
also, when declaring arrays, it is better to declare with syntax : int[] myArray;, not int myArray[] - as with
public static void main(String[] args), not (String args[]).this way is better coding and convention.
Last edited by JT4NK3D : 11-14-2007 at 06:18 AM.
Reason: accidentally posted before finished
|