/*

* Palindrome.java

*

* @author Mike Zastre (zastre@cs.uvic.ca)

* @version 1.0, 2008-06-20

*/

import java.util.*;

/** A class for generating and printing palindromes. */

public class Palindrome {

/** The main method for the Palindrome class. */

public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print(“Enter number: “); int num = sc.nextInt(); System.out.println(num + ” is ” + (isPalindrome(num)? “” : “not “) + “a palindrome.”); }

/** Returns true if the given number is a palindrome, false otherwise */

public static boolean isPalindrome(int n) { return n == reverse(n); } /** Returns the reverse of the given number */ public static int reverse(int n) { String str = “” + n; String revStr = “”; for (int i = str.length() – 1; i >= 0; i–) { revStr +=

import java.util.Scanner;

public class Palindrome {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

String s = scanner.nextLine();

int length = s.length();

for (int i = 0; i < length / 2; i++) { if (s.charAt(i) != s.charAt(length - 1 - i)) { System.out.println("NO"); return; } } System.out.println("YES"); } } class Palindrome { public static void main(String args[]) { int r,sum=0,temp; int n=454;//It is the number variable to be checked for palindrome temp=n; while(n>0){

r=n%10; //getting remainder

sum=(sum*10)+r;

n=n/10;

}

if(temp==sum)

System.out.println(“palindrome number “);

else

System.out.println(“not palindrome”);

}

}

// A Java program to check if x is palindrome or not

// A utility function to check if x is palindrome

class Palindrome

{

// Returns true if str is palindrome, else false

static boolean isPalRec(String str, int s, int e)

{

// If there is only one character

if (s == e)

return true;

// If first and last character do not match

if ((str.charAt(s)) != (str.charAt(e)))

return false;

// If there are more than two characters, check if middle substring is also palindrome or not.

if (s < e + 1) return isPalRec(str, s + 1, e - 1); return true; } static boolean isPalindrome(String str) // This function mainly uses isPalRec() { int n = str.length(); // An empty string is considered as palindrome if (n == 0) return true; return isPalRec package com.mycompany.mavenproject1; public class NewClass { public static void main(String[] args) { String pi = "314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664 import java.io.*; public class Palindrome { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { // TODO code application logic here int num, rem, orig, rev=0; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter any number : ");//inputting the number to be checked for palindrome or not. num = Integer.parseInt(br.readLine());//converting the input string into integer using Integer.parseInt() method of wrapper class Integer. orig = num;//storing the original value of num in a separate variable orig for later use in printing purpose. while(num != 0)//condition for checking whether the given number is palindrome or not. {//the condition will execute till num is not equal to zero and with each iteration it will remove last digit from the number and store it in rev as well as decrease its value by one digit by dividing it by public class Pi { public static void main(String[] args) { int max = 100000; int num = 0; for (int i = 3; i < max; i += 2) { if (i % 5 != 0 && (i - 1) % 24 == 0) { ++num; System.out.print(num); System.out.print(") "); System.out.println(i); } else if (i % 5 != 0 && (i + 1) % 24 == 0) { ++num; System.out.print(num); System.out.print(") "); System.out.println(-i); } else if (i == 9 || i == 99 || i == 999 || i == 9999 || i == 99999) { System.out.println(); } else if (i % 10 != 0 && num % 10 == 0) { System.out.println();}}}}

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

Artistic representation for Software Development Best Practices 2025

Software Development Best Practices 2025

Software Development Best Practices 2025 In an era where technology shapes every aspect of our lives, software development has become...

Artistic representation for Mapping the Unseen : How Satellite Images Reveal Port Moresby Hidden Urban Growth Australian Institute of International Affairs

Mapping the Unseen : How Satellite Images Reveal Port Moresby Hidden Urban Growth Australian Institute of International Affairs

This migration is driven by poverty, lack of employment, and limited access to basic services such as healthcare and education....

Artistic representation for Coding Tutorials: Essential Tools and Resources

Coding Tutorials: Essential Tools and Resources

Coding Tutorials: Essential Tools and Resources for Sustainable Living Enthusiasts In today's digital age, coding has become an indispensable skill...

How to Beautify PHP Code with php-beautifier

How to Beautify PHP Code with php-beautifier

How to Beautify PHP Code with php-beautifier: A blog on the benefits of using a beautifier. Any web developer that...

Leave a Reply

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