-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChangeTest.java
More file actions
34 lines (27 loc) · 780 Bytes
/
ChangeTest.java
File metadata and controls
34 lines (27 loc) · 780 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
class ChangeArray {
private int j;
public void print(int[] x) {
for (j = 0 ; j < x.length ; j++)
System.out.print(x[j] + " ");
System.out.println( );
}
public void zeroElt(int[] x, int elt) {
if (elt < x.length)
x[elt] = 0;
}
public void zeroAll(int[] ar) {
for (j = 0 ; j < ar.length ; j++)
ar[j] = 0;
}
}
public class ChangeTest {
public static void main(String[] args) {
ChangeArray cng = new ChangeArray();
int[] value = {27, 19, 34, 5, 12};
System.out.println("Before:");
cng.print(value);
cng.zeroAll(value);
System.out.println("After:");
cng.print(value);
}
}