-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNestedclass.java
More file actions
32 lines (30 loc) · 760 Bytes
/
Copy pathNestedclass.java
File metadata and controls
32 lines (30 loc) · 760 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
class Outer{
int age = 10;
String name = "Ravi";
void display(){
System.out.println("Outer class");
Inner obj = new Inner();
obj.display();
}
class Inner{
double cgpa = 9.0f;
void display(){
System.out.println(age);
System.out.println(name);
System.out.println(cgpa);
}
}
void show(){
Inner obj = new Inner();
System.out.println(obj.cgpa);
}
}
public class Nestedclass {
public static void main(String[] args) {
Outer obj1 = new Outer();
Outer.Inner objj = new Outer().new Inner();// obj1.new Inner();
obj1.show();
objj.display();
System.out.println(objj.cgpa);
}
}