
4.12 Simple IO and Arrays and String Vectors
20. System.out.print(“ “ + myArray[i]);
21. obj.Sort(myArray, len);
22. System.out.println(“ \nSorted Array ......”);
23. for(int i=0;i<len;i++)
24. System.out.print(“ “ + myArray[i]);
25. }
26. }
Output : Given Array ...... 10 13 17 20
Sorted Array ...... 20 17 13 10
Line No. 3: public void Sort(int myArray[], int len){ method defines
procedure for sorting an array. Observe that int myArray[] is
passed as an argument. No need to mention the dimension. Line No. 8
swaps the variable myArray[i] if myArray[i]<myArray[j]
as shown at Line No. 7.
Line No. 15: defines an object of IntSort1. Line No. ...