public class T08 { public static void main(String[] args) { int[]arr=new int[]{33,55,2,6,-8,-5,66,1,63}; for(int i=0;i< arr.length-1;i++){ for(int j=0;j< arr.length-1-i;j++){ if(arr[j]>arr[j+1]){ int a=arr[j]; arr[j]=arr[j+1]; arr[j+1]=a; } } } for(int i=0;i< arr.length;i++) { System.out.println(arr[i]); } } }
The above is the detailed content of Methods and examples of bubble sorting in Java. For more information, please follow other related articles on the PHP Chinese website!