+ 1

is it possible to get the array pointer [][] by using the scanner mathod.

is it acorrect code line int arr[][]=S.nextInt();

27th Jun 2017, 3:13 PM
Yehuda
Yehuda - avatar
3 Answers
+ 2
Like this? int[] array = new int[2]; array[0] = S.nextInt(); array[1] = S.nextInt();
27th Jun 2017, 5:18 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
No. You're assigning the array to an int value, int cannot have characters like [[ or @, and is not of type int[][]. You can however assign the reference of one array to another array. Example/ int[] arr1 = {4,6,2}; int[] arr2 = arr1; // arr2 is now pointing to the same location as arr1. If you want to see the reference, you can print the arrays toString. System.out println(arr1); // like this Ps: Scanner is not a method.
27th Jun 2017, 4:23 PM
Rrestoring faith
Rrestoring faith - avatar
0
I want to assign(by using the keyboard) two ints to be my array pointer and then to enter anumber to the array as the value of this array cell. and to get it by using scanner
27th Jun 2017, 5:06 PM
Yehuda
Yehuda - avatar