-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTut37.java
More file actions
43 lines (34 loc) · 690 Bytes
/
Tut37.java
File metadata and controls
43 lines (34 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package tutorial;
//inner class and outer class
class Outer {
public int a;
public int b;
public Outer(int a, int b) {
this.a = a;
this.b = b;
}
public void Outermethod() {
System.out.println("Called the Outer class" + this.a);
}
class Inner {
public int c;
public int d;
public Inner(int c, int d) {
this.c = c;
this.d = d;
}
public void Innermethod() {
System.out.println("Called the Inner class" + this.c);
}
}
}
public class Tut37 {
public static void main(String[] args) {
// Outer class calling
Outer c = new Outer(1, 2);
c.Outermethod();
Outer.Inner inn = c.new Inner(3, 2);
System.out.println(inn.c);
inn.Innermethod();
}
}