-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathInnerClassDemo.java
More file actions
80 lines (75 loc) · 1.32 KB
/
InnerClassDemo.java
File metadata and controls
80 lines (75 loc) · 1.32 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
class T
{
void print(){
int pp=100;
System.out.println("T Print Call..");
class E
{
void display(){
//pp++;
//System.out.println("E Display Call..."+pp);
}
} // class end
pp++;
System.out.println("PP is "+pp);
E obj = new E();
obj.display();
} // method end
}
class A
{
static class B
{
static void show(){
System.out.println("B Show...");
}
}
}
class Outer
{
int x =10;
Outer(){
System.out.println("Outer Class Cons Call");
// 1st Way
//Inner inner = new Inner();
}
interface P
{
void print();
}
class Parent implements P{
int x = 100;
Parent(){
System.out.println("I am Paren Class");
}
public void print(){
System.out.println("Parent Print Call");
}
}
// Member Class
class Inner extends Parent
{
int x=20 ;
Inner(){
System.out.println("Inner Class Cons Call");
}
Inner(int x){
int z = Outer.this.x + this.x + x + super.x;
System.out.println("Z is "+z);
}
}
}
public class InnerClassDemo {
public static void main(String[] args) {
//Outer outer =new Outer();
// 2nd way
//Outer.Inner inner = outer.new Inner();
// 3rd Way
// Outer.Inner obj = new Outer().new Inner(90);
// // TODO Auto-generated method stub
// Outer.Parent p = new Outer().new Parent();
// A.B.show();
T obj = new T();
obj.print();
}
}