JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Robot {
int id = 5;
Robot(int i) {
Brain b = new Brain();
id = i;
b.think();
}
private class Brain {
public int a = id;
public void think() {
System.out.println(id + " is thinking about " + a);
}
}
}
public class Program {
public static void main(String[] args) {
Robot r = new Robot(1);
}
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run