KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have original array of public static void main (String[] arg) { int[] array = {1,5,6,8,4,2} for (int i = 0; i < array.length; i++) { System.out.print("List 1 = " + array[i] + ","); } swap(array); for (int i = 0; i < array.length; i++) { System.out.print("List 2 = "+array[i] + ","); } } private static int swap (int[] list){ Arrays.sort(list); } The output is List 1 = 1,5,6,8,4,2 List 2 = 1,2,4,5,6,8 What I want the answer to be is List 1 = 1,5,6,8,4,2 List 2 = 1,5,6,8,4,2 even after sorting. How can I do it?
Tags (comma-separated)
Save Edits
Cancel