I am trying to write a method to see if the string is a palindrome (Words that can be spelled correctly backwards too, for example "racecar". I cant find the error so maybe another set of eyes will help. Here is the code:
public boolean isPalindrome(String str){
numberofQuestions++;
int n = str.length();
for( int i = 0; i < n/2; i++ )
if (str.charAt(i) != str.charAt(n-i-1)) return false;
return true;
}
EDIT: Screenshot of errors:
Start of class:
public class Geek{
private String name;
private int numberofQuestions=0;
Final Edit: Found an extra "{" inside one of the methods. Thanks to everyone for your help!