-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNestedClass.java
More file actions
36 lines (27 loc) · 951 Bytes
/
NestedClass.java
File metadata and controls
36 lines (27 loc) · 951 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
package Practice081918;
//demonstration accessing of a static nested class
//outer class
public class NestedClass {
// static member
static int outer_x = 10;
// instance(non-static) member
int outer_y = 20;
// private member
private static int outer_private = 30;
// static nested class
static class StaticNestedClass
{
void display()
{
// can access static member of outer class
System.out.println("outer_x = " + outer_x);
// can access display private static member of outer class
System.out.println("outer_private = " + outer_private);
// The following statement will give compilation error
// as static nested class cannot directly access non-static membera
// System.out.println("outer_y = " + outer_y);
// trying to do something.
//lets push this on github.
}
}
}