Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Write a JAVA program to sort the plastic data in the array. It is required to implement a sorting method separately and call the sorting party in the main method.
Write a JAVA program to sort the plastic data in the array. It is required to implement a sorting method separately and call the sorting party in the main method.
Common class sorting {

Public static void main(String[] args) {

int[]array = { 4 12,5,9,2,4,2 1,- 15,88 };

System.out.println ("original array:");

PrintArray (array);

Sorting (array);

system . out . println();

System.out.println ("sorting result:");

PrintArray (array);

}

/**

* print array

* @param array

*/

public static void print array(int[]array){

for(int I = 0; I < array. Length; i++) {

system . out . print(array[I]+" ");

}

}

/**

* bubble sorting

* @param array

*/

Public static void sort (int [] array) (

int tmp

for(int I = 0; I < array. Length; i++) {

for(int j = 0; j & ltarray . length- 1; j++) {

if(array[j]& gt; array[j+ 1]){

tmp = array[j];

array[j]= array[j+ 1];

array[j+ 1]= tmp;

}

}

}

}

}