Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 3
it's a bit unclear. Do you mean something like this?
public class Main {
public static void main(String[] args) {
int[][] a = {
{1, 2, 3},
{4, 5, 6}
};
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
System.out.printf("%d ", a[i][j]);
}
System.out.println();
}
}
}
out:
1 2 3
4 5 6
+ 3
I think this lesson is what u r asking for :
https://www.sololearn.com/learn/Java/2149/?ref=app
+ 3
in Java11+ you can try this as well
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int[][] matrix = {
{8, 1, 6},
{3, 5, 7},
{4, 9, 0},
};
for (var i : matrix) {
System.out.println(Arrays.toString(i));
}
}
}
out;
[8, 1, 6]
[3, 5, 7]
[4, 9, 0]
+ 3
Most Welcome š, Ok No Problem.
+ 2
If you use System.out.println() it'll print a newline characters at end of string.
If you have already tried to solve this please share your code here so others can see what's wrong in it.
If you don't know how to share code read this:
https://www.sololearn.com/post/75089/?ref=app
+ 2
Flash,
Starting from Java 10, actually.
https://developer.oracle.com/java/jdk-10-local-variable-type-inference.html
For lower versions of Java that var can be replaced by int[]
for(int[] a: matrix) {}
+ 1
š®š³Omkarš thanks
0
Aysha Simra where did get 2? what kind of order is that?