0

How can I get retrieve array?

10th Aug 2016, 6:10 PM
Yash diwan
Yash diwan - avatar
3 Réponses
0
You should use name of variable and index. For example: int[] arr = new int[5]; arr[2] = 13; a = arr[2]; System.out.print(a); or you can print value of arr[2] without assigment operator, that is System.out.print(arr[2]).
12th Aug 2016, 7:58 AM
Yevgeniy Ponomarev
Yevgeniy Ponomarev - avatar
0
If you want to print all values of array you should use loop.
12th Aug 2016, 7:58 AM
Yevgeniy Ponomarev
Yevgeniy Ponomarev - avatar
0
example: public static void main(String[] args){ int[] arr = new int[10]; for (int i = 0; i < 10; i++) { arr[i] = i * 2; System.out.println(arr[i]); } }
12th Aug 2016, 8:05 AM
Yevgeniy Ponomarev
Yevgeniy Ponomarev - avatar