I recently started to work with Java. As you already know, it's very similar to some other programs like C so I didn't start as a total newbie. Anyway there's always a first time to ask for help. Here is the thing:
My quest starts with creating a two-dimensional field, a filling it with some integer numbers. It should look like this:
0 0 0 0 0
0 1 2 3 4
0 2 4 6 8
0 3 6 9 12
0 4 8 12 16
int[][] matrix; matrix = new int[5][5];
I already filled the matrix using inner and outer "for" loop. The integers are IN. There's no need for me to paste that code. My question is. How to print(onscreen) whole array using the standard 'for' iteration( format: (for(int item:array))
This is the way teacher said it has to be done. I tried and got nowhere. The construction stated above can only be used to iterate through simple, 1-dimensional array. Here's the example:
public static void main(String[] args){
int[] numbers = {1,2,3,4,5,6,7,8,9,10};
for (int item : numbers) {
System.out.println("Count is: " + item);
}
}
What's a solution for 2 dimensional field?
p.s. I can post more code and progress if necessary. Thanks in advance :)
Regards from Croatia.


Sign In
Create Account


Back to top









