-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodeforReferencetypesandValuetypesvideo.java
53 lines (29 loc) · 1.39 KB
/
CodeforReferencetypesandValuetypesvideo.java
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
41
42
43
44
45
46
47
48
49
50
51
52
import java.util.Arrays;
public class CodeforReferencetypesandValuetypesvideo{
public static void main(String[] args) {
int firstInt = 9;
int secondInt = firstInt;
System.out.println("The first int value is : " +firstInt);
System.out.println("The second int value is : " +secondInt);
secondInt = secondInt + 1;
System.out.println("The new first int value is : "+firstInt);
System.out.println("The new second int value is : "+secondInt);
int[] myFirstArray = new int[7];
int[] mySecondArray = myFirstArray;
System.out.println("My first array is : "+ Arrays.toString(myFirstArray));
System.out.println("the second array is"+ Arrays.toString(mySecondArray));
mySecondArray[5] = 1;
System.out.println("the updated first array is"+ Arrays.toString(myFirstArray));
System.out.println("the updated second array is"+ Arrays.toString(mySecondArray));
modifyArray(mySecondArray);
System.out.println("the modified first array is"+ Arrays.toString(myFirstArray));
System.out.println("the modified second array is "+ Arrays.toString(mySecondArray));
mySecondArray = new int[7];
mySecondArray[0] = 10;
System.out.println("the latest first array is "+ Arrays.toString(myFirstArray));
System.out.println("the latest second array is "+ Arrays.toString(mySecondArray));
}
public static void modifyArray(int[] array){
array[2] = 1;
}
}