We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1770539 commit f9281efCopy full SHA for f9281ef
1 file changed
src/testPassArray.java
@@ -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
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