-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathStaticDemo.java
More file actions
49 lines (45 loc) · 883 Bytes
/
StaticDemo.java
File metadata and controls
49 lines (45 loc) · 883 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 static java.lang.System.out;
import static java.lang.Math.pow;
class A1
{
static int x;
int y;
private A1(){
x++;
y++;
System.out.println("X "+x+" and Y "+y);
}
static{
System.out.println(" I am Static Block"
+ " and Call When Class is Loaded... "+x);
}
static void print(){
System.out.println(" iam static method ");
}
}
interface A2
{
static void show(){
System.out.println("I am Static ...");
}
}
class OuterClass{
static class NestedClass{
static void print(){
System.out.println("Nested Class Print...");
}
}
}
// Utility Class = private cons + static methods
public class StaticDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
OuterClass.NestedClass.print();
out.println(A1.x);
A1.print();
//Math math = new Math();
pow(2, 3);
//A1 obj = new A1();
//A1 obj2 = new A1();
}
}