Java says this method has a constructor name

You can’t use the class name as the name for a method. The only “methods” that can share a name with the class are constructors.

One fix would be to rename your class from isPalindrome to PalindromeFinder or something. That would also better align with Java naming conventions.

EDIT: Note that you never actually called your method in main; you tryed to assign a local variable to isPalindrome. That does not actually call the method. You would need to invoke the method with isPalindrome(...put your parameters here...) and store the result in a variable with a name that isn’t being used.

Also note that a method can only return a single value (a single primitive or a single object). If you really want to return an array AND a boolean (and I’m not sure you do), you would have to store those in an object and return that object.

Leave a Comment