I'm a beginner in java. I have question about for each. can I use it in order to get input from user? If yes, How?
I tried this code, but didn't work:
Scanner scanner = new Scanner(System.in);
int[] arr = new int[3];
for(int m: arr){
m = scanner.nextInt();
}
//arr[0] = 1 , arr[1] = 5 , arr[2] = 61
But when I printed my array:
0 0 0
was shown.