You can't nest a method within another method
so put public void compareArray(){}
outside main
method.
class createArray {
public static void main(String args[]) { . . .}///this is a method
public void compareArray() { . . . }///and this is another method
}///End of the class