0
Who can explain how does array work? And how can I use it?
I don't understand it at all...
2 ответов
+ 3
for example, u wanna compare 3 numbers, u can 3 variable or u can interger array, like:
Scanner scan = new Scanner (System.in);
System.out.print("Please first number: ");
int x= scan.nextInt();
System.out.print("Please second number: )";
int y= scan.nextInt();
System.out.print("Please third number: ");
int z= scan.nextInt();
OR
int [] arrayInt = new Int[3];
for (int i = 1;i<=3;i++){
System.out.print("Please"+ i+".number: ");
array[i]= scan.nextInt();
}
i hope, i can help u :) i did not compare the numbers, i take the value from user, importat thing is here array :)
+ 2
it is matrix,especially 2d is most common used.
For Example:
int [][] arr = new int [2][3] ; // it looks like that:
// 1. column 2.column 3.column
arr[0][0] arr[0][1] arr[0][2] //1.row
arr[1][0] arr[1][1] arr[1][2] //2.row
// instead of int , u can string, long, float...,