Gabbie Gabbie - 4 months ago 26
Java Question

Cannot Find Symbol Error: Trying To Call a Method

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

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);
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?


Static methods are referred by Class name. You should be calling the method as

   System.out.print(ArrayHelper.sortIntoGroups(testArray, partitionVal));

Hope that helps :)