THINK FIRST·CODE LATER

← All labs

StringBuilder: reverse and palindrome

Problem

Write a class Palindrome with a method

public static boolean isPalindrome(String text)

that returns true when the text reads the same in both directions, ignoring case, spaces and punctuation (keep only letters and digits). Use StringBuilder and its reverse() method.

main reads one line and prints:

Reversed: amanaplanacanalpanama
Palindrome: true

Reversed shows the cleaned text reversed (lower case, letters and digits only).

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.