-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargPass.java
53 lines (43 loc) · 1.32 KB
/
argPass.java
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
/**
* Demonstration of Inner classes in Java
*
*/
class Outer {
int a = 10;
static int b = 20;
class Inner {
void getIntegerValue() {
Outer o = new Outer();
System.out.println("the value of the non.sattic variable in the outer class is: " + o.a);
System.out.println("the value of the static variable in outer class is: " + b);
}
}
static class staticInnerClass {
void getClassData() {
System.out.println("value of the outer class static variable is: " + b);
Outer out = new Outer();
System.out.println("the value of the outer non-static variable is: " + out.a);
}
}
static void showInt() {
System.out.println("value of static variable is: " + 10);
}
}
public class argPass {
public static void main(String... args) throws Exception {
/*
* the difference between static and
* non static inner class object creation
*/
Outer out = new Outer();
Outer.Inner in = out.new Inner(); // Object creation of non-static Inner class
Outer.staticInnerClass in2 = new Outer.staticInnerClass(); // Object creation of static inner class
System.out.println("Non-Static inner Class method called");
in.getIntegerValue();
System.out.println();
System.out.println("Static Inner Class method called");
in2.getClassData();
}
}
class Test {
}