How can i resolve this error in below code?

On the first line of your method, you have:

boolean isAmazing(int checkNum, counter){

The counter variable has no type associated with it. it should look more like this:

boolean isAmazing(int checkNum, int counter){

Putting that together and being properly formatted should look more like the following:

boolean isAmazing(int checkNum, int counter){
    for(int i = 1; i <= checkNum/2; i++){
        if(checkNum/i==0){
            counter++;
            if(counter>2){
                return false;
            }
        }
     }
     return true;
}

Java is a strongly typed language, meaning that all variables have to have a type and can not change that type.

Leave a Comment