Palindrome

Lab Java Beginner 10 points

Read a word and print true if it reads the same backwards (ignoring case), else false.

Input

One word.

Output

true or false

Example

Input

Level

Output

true
Sample input available Sample output available
Editor
Java

Hints

Compare the word with its reverse using equals.

Solution explanation

Remember toString(): a StringBuilder is not a String.

Show solution
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.next().toLowerCase();
        String reversed = new StringBuilder(w).reverse().toString();
        System.out.println(w.equals(reversed));
    }
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD