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

The Green Path to Innovation: Sustainable Practices in API Development

The Green Path to Innovation: Sustainable Practices in API Development In an era where technology drives progress, the intersection of...

What Makes The Best Desk for Your Office A blog about the best desks for offices. http

What Makes The Best Desk for Your Office A blog about the best desks for offices. http

The leap year program in python is one of the best ways to get started learning programming. It is a...

Pandas Eating Bamboo is sooooooo cute... Pandas are very fascinating animals, there are so many interesting facts about them. Though they appear harmless the Red Panda is a carnivore that eats birds, eggs and small animals. Here are some of the most intriguing panda facts

Pandas Eating Bamboo is sooooooo cute... Pandas are very fascinating animals, there are so many interesting facts about them. Though they appear harmless the Red Panda is a carnivore that eats birds, eggs and small animals. Here are some of the most intriguing panda facts

Pandas Eating Bamboo is sooooooo cute Pandas are very fascinating animals, there are so many interesting facts about them. Though...

5 Reasons to Work With Our HTML5 Web Development Company

5 Reasons to Work With Our HTML5 Web Development Company

5 Reasons to Work With Our HTML5 Web Development Company A blog about our development services and how we can...

Leave a Reply

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