java - Eclipse is not allowing me to write the method for finding MiddleElement -


i'm writing method find middle element given 3 numbers eclipse not allowing me so. please me should do? code below:

public class middleelement {       public static void main(string[] args) {          int x = 5;         int y = 1;         int z = 4;          int[] = {x,y,z};          int length = a.length;          bubblesort(a,length);          system.out.println("sorted elements are:");         for(int i=0;i<length;i++){              system.out.print(a[i]);         }      }       //method bubble sort elements      public static void bubblesort(int[] , int len){                  int i,j,temp;                      (i = 0; < len;i++){                              for( j = 1; j < (len-1); j++){                                  if(a[j-1]>a[j]){                                     temp = a[j-1];                                     a[j-1] = a[j];                                     a[j] = temp;                                  }                             }                     }// end of method bubblesort       public static int findmiddle(int[] a){           }      }// end of main method  } 

thanks in advance help.

you missing closing brace bubblesort method. without compiler complains illegal public keyword modifer intended subsequent findmiddle method.

public static void bubblesort(int[] , int len){     int i,j,temp;    (i = 0; < len;i++) {       for( j = 1; j < (len-1); j++) {        ...       }    }// end of method bubblesort } <-- add 

make sure return value findmiddle method.

aside: java naming conventions indicate methods begin lowercase letter , use camelcase such bubblesort.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -