+ 2

Can anyone please help me with the flow of the program?

class Evaluvate { public static void main(String args[]) { int arr[]=new int[] {0,1,2,3,4,5,6,7,8,9}; int n=6; n=arr[arr[n]/2]; System.out.print(arr[n]/2); } }

28th Sep 2018, 6:42 PM
ashwith
ashwith - avatar
9 Answers
0
I hope it will help n = 6 n = arr[arr[6]/2] = arr[6/2] = arr[3] = 3 System.out.println(arr[3] / 2) = 3 / 2 = 1
28th Sep 2018, 7:38 PM
Daniel (kabura)
Daniel (kabura) - avatar
0
error :) What is it "arr" in your code
28th Sep 2018, 7:32 PM
Daniel (kabura)
Daniel (kabura) - avatar
0
How come arr[6/2]=arr[2] can you please explain?
28th Sep 2018, 7:39 PM
ashwith
ashwith - avatar
0
I'm sorry my mistake :)
28th Sep 2018, 7:42 PM
Daniel (kabura)
Daniel (kabura) - avatar
0
no i reffered many websites..the answer you explained was correct..but i kind of dint get the logic😂
28th Sep 2018, 7:43 PM
ashwith
ashwith - avatar
0
Thank you😊
28th Sep 2018, 7:43 PM
ashwith
ashwith - avatar
0
I'm glad that I could help :)
28th Sep 2018, 7:44 PM
Daniel (kabura)
Daniel (kabura) - avatar
0
😃
28th Sep 2018, 7:45 PM
ashwith
ashwith - avatar
- 1
sorry!its array
28th Sep 2018, 7:33 PM
ashwith
ashwith - avatar