-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathStaticDemo.java
More file actions
54 lines (33 loc) · 756 Bytes
/
StaticDemo.java
File metadata and controls
54 lines (33 loc) · 756 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
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.Scanner;
class M
{
static{
System.out.println("M Static Call");
}
}
class P
{
int x; // When Object is Created
static int y; // When Class is Loaded
P(){
x++;
y++;
System.out.println("I am Call When Object is Created X "+x+" Y "+y);
}
static{
System.out.println("I am P Call When Class is Loaded... "+y);
}
}
public class StaticDemo {
public static void main(String[] args) throws Exception{
//TT obj = new TT();
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the Class Name to Load");
String className = scanner.next();
Class.forName(className);
//System.out.println(P.y);
/*P obj1 = new P();
P obj2 = new P();
P obj3 = new P();*/
}
}