0
issue with an inner class
why is it that the variable "id" is shown as both 1 and 5 in this code?? when I want it to show id itself it shows 1 but when I assign the same "id" variable to variable "a" it shows its initial value of 5! https://code.sololearn.com/cqHlwnZqvB3R/?ref=app
3 ответов
+ 4
Swap statements at line 4 and 5, you'll see why 👍
+ 3
salar vahidi
When you create object of inner class in Robot constructor then id assigned value to a so here a will be 5
After creating object of the inner class, you assigned value of i to id so here id will be 1