Bubble sort code on Java -


this code supposed bubble sort eclipse keep telling me there syntax errors on line 9:

- syntax error on token "(", { expected   - syntax error on token "arr", ( expected after token 

anyone knows happening?

package porra;  public class vai {  public static final int arraylen = 0;  public static void main(string[] args){  class bubblesort (int[] arr) {   boolean swap = true; int = 0, j = 0, temp; while (swap) {     swap = false;     j++;     (i = 0; < arraylen - j; i++) {         if (arr[i] > arr[i + 1]) {             temp = arr[i];             arr[i] = arr[i + 1];             arr[i + 1] = temp;             swap = true;         }     }     system.out.print("ordem" + j + " : ");     this.printarray(arr);     system.out.println(""); } return; } private void printarray(int[] arr2) { // todo auto-generated method stub } } } } 

you're mixing class declaration constructor declaration. this:

class bubblesort{   public static sort(int[] arr){     boolean swap = true;     ...etc...     system.out.println("");   }   public static void main(string[] args){     int[] nums = {1,43,7,8};     bubblesort.sort(nums);   } } 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -