-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticKeyword.java
More file actions
32 lines (26 loc) · 973 Bytes
/
StaticKeyword.java
File metadata and controls
32 lines (26 loc) · 973 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
/*Static Keyword = The Static Keyword in java is used for memory management primarily
It can be applied on variables , blocks ,nested classes & methods. */
// public class StaticKeyword {
// String name;
// static String school;
// public static void main(String... s) {
// StaticKeyword.school = "SNPS";
// System.out.println(StaticKeyword.school);
// }
// }
//A static keyword contain things can take memory one time only but objects can take multiple time
public class StaticKeyword {
String name;
static String school;
public void changeschool() {
school = "Indraprastha";
}
public static void main(String[] args) {
StaticKeyword.school = "Sant Nirankari Public School";
StaticKeyword student = new StaticKeyword();
student.changeschool();
student.name = "Kushant";
System.out.println(student.name);
System.out.println(school);
}
}