Question: public static void swap(int n1, int n2){ int temp = n1; n1 = n2; n2 = temp; } public static void main(String[ ] args){ int[
public static void swap(int n1, int n2){ int temp = n1; n1 = n2; n2 = temp; } public static void main(String[ ] args){ int[ ] array = {1,2,3,4,5}; swap(array[1], array[4]); for(int i=0; i < array.length; i++){ System.out.print(array[i] + ); } }
what would be the answer for this coding? I got errors...
| a)1,5,3,4,2 | |
| b) | 1,2,3,4,5 |
| c) | 4,2,3,1,5 |
| d) 5,4,3,2,1
(answer should be one of above the list) |
please help me out! (java)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
