-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnonstatic_class.java
More file actions
48 lines (37 loc) · 1.32 KB
/
nonstatic_class.java
File metadata and controls
48 lines (37 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
import java.util.*;
import java.io.*;
class Outer{
public int x;
public static int y;
public static void fun(){
System.out.println("I am fun function ");
System.out.println("value of y : "+y);
// System.out.println("value of y : "+x); ////this we cannot do as it was not declared as static
}
static class inner{
public int x2;
// public static int y2;
public void fun2(){
System.out.println("hello Guys");
fun();
}
}
static class inner2{
public int x3;
public static int y3;
public void fun3(){
System.out.println("You are inner2 function ");
fun();
}
}
}
public class nonstatic_class {
public static void main(String[] args) {
// Outer obj1=new Outer(); ////this is for the outer class is we want to apply to call any function than we have to call by object like obj1.fun() we are callng
// obj1.fun();
Outer.inner2 obj1=new Outer.inner2();
obj1.fun3(); /////in this as we are calling the inner class so we are writing outer.inner and calling obj1
Outer.inner obj2=new Outer.inner();
obj2.fun2();
}
}