Skip to content

Commit f9281ef

Browse files
authored
Add files via upload
1 parent 1770539 commit f9281ef

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/testPassArray.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
public class testPassArray {
2+
public static void main(String[] args) {
3+
int [] a={1,2};
4+
System.out.println("Before invoking the swap ");
5+
swap(a[0],a[1]);
6+
System.out.println("Answer"+a[0]+"&&"+a[1]);
7+
System.out.println("After invoking the swap ");
8+
swapInArrays(a);
9+
System.out.println("Answer"+a[0]+"&&"+a[1]);
10+
}
11+
12+
13+
public static void swap(int n1, int n2){
14+
int temp=n1;
15+
n1=n2;
16+
n2=temp;
17+
18+
}
19+
public static void swapInArrays(int[]array){
20+
int temp=array[0];
21+
array[0]=array[1];
22+
temp=array[1];
23+
}
24+
}

0 commit comments

Comments
 (0)