I am working on an assignment for my introductory Java class and have run into an error I cannot seem to figure out! I must create a static sortIntoGroups
method that partitions an array without using any while loops. The method must be callable from a separate driver class. I am currently trying to test it out with a main method but for some reason it does not seem to recognize the method. Here is my code:
public class ArrayHelper{
public class ArrayHelper{
public static int sortIntoGroups (int[] arrayToSort, int partitionValue){
int i = 0;
int j = (arrayToSort.length-1);
do{
for(i=0; i < partitionValue; i++ ){
for(j = (arrayToSort.length-1); j > partitionValue; j--){
if (i < j){
int tempVar = arrayToSort[i];
arrayToSort[i] = arrayToSort[j];
arrayToSort[j] = tempVar;
}//end if
}//end j for
}// end i for
}while(i< j);
return j;
}//end sortIntoGroups
public static void main (String [] args){
int [] testArray = {1, 2, 3, 4, 5};
int partitionVal = 4;
System.out.print(testArray.sortIntoGroups(testArray, partitionVal));
}
}
Any ideas? Thanks!