-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstantExample
More file actions
25 lines (20 loc) · 913 Bytes
/
ConstantExample
File metadata and controls
25 lines (20 loc) · 913 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
public class ConstantExample {
int instanceVariable = 10;
static int staticVariable = 20;
final int CONSTANT_INSTANCE_VARIABLE = 100;
static final int CONSTANT_STATIC_VARIABLE = 200;
public void display() {
int localVariable = 30;
final int CONSTANT_LOCAL_VARIABLE = 300;
System.out.println("Instance Variable: " + instanceVariable);
System.out.println("Static Variable: " + staticVariable);
System.out.println("Constant Instance Variable: " + CONSTANT_INSTANCE_VARIABLE);
System.out.println("Constant Static Variable: " + CONSTANT_STATIC_VARIABLE);
System.out.println("Local Variable: " + localVariable);
System.out.println("Constant Local Variable: " + CONSTANT_LOCAL_VARIABLE);
}
public static void main(String[] args) {
ConstantExample example = new ConstantExample();
example.display();
}
}