Share your repls and programming experiences

← Back to all posts
Palindrome string program in java using scanner
RaghunathThilag (1)

Palindrome string program in java using scanner. Learn how to write a program to print palindrome or not in java using letters. In the Java programming language, you can make a palindrome or not. The topic of this program is whether or not the word is a palindrome. Madam,malayalam. maam is a title, phrase, or sequence that reads the same backwards as forwards.

import java.util.*;

class Main
public static void main(String args[])
String a, b = "";
Scanner in = new Scanner(;
System.out.println("Enter the string");
a = in.nextLine();
int length = a.length();
for (int i = length - 1; i >= 0; i--)
b = b + a.charAt(i);
System.out.println("The string is a palindrome.");
System.out.println("The string is not a palindrome.");

Enter a string


the string is a palindrome