-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatics.java
More file actions
32 lines (19 loc) · 870 Bytes
/
Statics.java
File metadata and controls
32 lines (19 loc) · 870 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
package javaIntroduction;
public class Statics {
static int temp = 20; //private
public static void main(String[] args) {
//System.out.println(Statics.temp); //ClassName.varibleName
Statics sts1 = new Statics();
Statics sts2 = new Statics();
Statics sts3 = new Statics();
System.out.println("sts1 before:"+ sts1.temp);
System.out.println("sts2 before:"+ sts2.temp);
System.out.println("sts3 before:"+ sts3.temp);
temp += temp; //temp = temp + temp; = 20 +20
System.out.println("sts1 after:"+ sts1.temp);
sts2.temp = 99;
System.out.println("sts2 after:"+ sts2.temp);
System.out.println("sts3 after:"+ sts3.temp);
System.out.println("sts1 after:"+ sts1.temp);
}
}