import java.util.Scanner;

public class Palindrome {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

System.out.print(“Enter a word to check whether it is a palindrome or not: “);

String word = in.nextLine();

int length = word.length();

int i, begin, end, middle;

begin = 0;

end = length – 1;

middle = (begin + end)/2;

for (i = begin; i <= middle; i++) { if (word.charAt(begin) == word.charAt(end)) { begin++; end--; } else { break; } } if (i == middle + 1) { System.out.println("This is a palindrome."); } else{ System.out.println("This is not a palindrome."); } } } public class Palindrome { public static void main(String[] args) { int number = 121; int reversedInteger = 0; int remainder = 0; int originalInteger; originalInteger = number; // reversed integer is stored in variable while (number != 0) { remainder = number % 10; reversedInteger = reversedInteger * 10 + remainder; number /= 10; } // palindrome if orignalInteger and reversedInteger are equal if (originalInteger == reversedInteger) { System.out.println(originalInteger + " is a palindrome."); } else { System.out.println(originalInteger + " is not a palindrome."); } } } import java.util.Scanner; public class Palindrome { public static void main(String args[]) { String a, b = ""; Scanner s = new Scanner(System.in); System.out.print("Enter the string you want to check:"); a = s.nextLine(); int n = a.length(); for(int i = n - 1; i >= 0; i–)

{

b = b + a.charAt(i);

}

if(a.equalsIgnoreCase(b))

System.out.println(“The string is palindrome.”);

A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as madam or racecar. Sentence-length palindromes may be written when allowances are made for adjustments to capital letters, punctuation, and word dividers, such as “A man, a plan, a canal: Panama”, “Was it a car or a cat I saw?” or “No ‘x’ in Nixon”.

This program will check whether the given string is palindrome or not.

Any string with less than two characters is a palindrome.

The first character in the string should be equal to the last one.

The second character in the string should be equal to the second last one.

And so on…

If all these comparisons are true, then it is a palindrome. If any of these comparisons are false, then it is not a palindrome.

A Palindrome is a word, or phrase that reads the same forward or backward. Examples of palindromes are:

Radar, deified, and malayalam

A palindrome can be a word, number, phrase, or other sequence of characters which reads the same backward as forward. The word “palindrome” was coined from the Greek roots palin (“again”) and dromos (“way, direction”). A simple example of a palindrome is the word “racecar”, which is spelled the same way backwards and forwards.

Palindromes are words, phrases, or sequences that read the same backward as forward, e.g., madam or nurses run. A palindrome is a word, phrase, number or other sequence of units that has the property of reading the same in either direction (the adjustment of punctuation and spaces between words is generally permitted).

Tomy

Tomy is a contributor at AskMeCode. We are committed to providing well-researched, accurate, and valuable content to our readers.

You May Also Like

4 Challenges of Using Low Code Platforms

4 Challenges of Using Low Code Platforms

About a decade ago, low-code platforms first appeared in the market. Now, they are gaining popularity among young developers who...

Web Design | Ecommerce | Digital Marketing| Design - Google Sheets- a portfolio of web design services and information on Google Sheets.

Web Design | Ecommerce | Digital Marketing| Design - Google Sheets- a portfolio of web design services and information on Google Sheets.

Web Design | Ecommerce | Digital Marketing| Design - Google Sheets- a portfolio of web design services and information on...

8 Common {jslint} Mistakes and How to Prevent Them

8 Common {jslint} Mistakes and How to Prevent Them

Using {jslint} can make your code more robust. It is a static analysis tool that allows JavaScript developers to quickly...

What are the Top Benefits of a Cloud Based Platform?

What are the Top Benefits of a Cloud Based Platform?

A cloud platform is a service or set of services offered by a cloud provider. The most common services are...

Leave a Reply

About | Contact | Privacy Policy | Terms of Service | Disclaimer | Cookie Policy
© 2026 AskMeCode. All rights reserved.