-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticVariable.java
More file actions
30 lines (21 loc) · 529 Bytes
/
StaticVariable.java
File metadata and controls
30 lines (21 loc) · 529 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
package oop;
public class StaticVariable {
int rollno;
String name;
static String college = "ITS";
StaticVariable(int r, String n) {
rollno = r;
name = n;
}
void display() {
System.out.println(rollno + " " + name + " " + college + "\n");
}
public static void main(String args[]) {
StaticVariable s1 = new StaticVariable(111, "Karan");
StaticVariable s2 = new StaticVariable(222, "Aryan");
s1.display();
StaticVariable.college = "ASCOL"; // s1.college = "ASCOL"
s1.display();
s2.display();
}
}