-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVariableActivity.java
More file actions
40 lines (26 loc) · 861 Bytes
/
VariableActivity.java
File metadata and controls
40 lines (26 loc) · 861 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
package javaTraining.module1;
public class VariableActivity {
/* TODO #1 Declare :
1. Instance variables with primitive and object variables
2. Class variables with primitive and object variables
3. Local variables with primitive and object variables
*/
//Instance
public int a1=1;
//Class
public static int a2=2;
//Local
public void getVariable3(int a3){
System.out.println(a3);
}
// END TODO #1
// TODO #2: initialize previously declared instance variable with some value in one method and output it in other method
// Is it possible to have access to local variable from multiple methods?
public static void main(String[] args){
VariableActivity va = new VariableActivity();
System.out.println(va.a1);
System.out.println(a2);
va.getVariable3(3);
}
// END TODO #2
}