Answers for "palindrome of number in java"

6

easy palindrome program in java

import java.util.*;   
class PalindromeExample2  
{  
   public static void main(String args[])  
   {  
      String original, reverse = ""; // Objects of String class  
      Scanner in = new Scanner(System.in);   
      System.out.println("Enter a string/number to check if it is a palindrome");  
      original = in.nextLine();   
      int length = original.length();   
      for ( int i = length - 1; i >= 0; i-- )  
         reverse = reverse + original.charAt(i);  
      if (original.equals(reverse))  
         System.out.println("Entered string/number is a palindrome.");  
      else  
         System.out.println("Entered string/number isn't a palindrome.");   
   }  
}
Posted by: Guest on August-28-2020
0

is palindrome java

public static boolean checkPalindrome(String str)
{     
 
    int len = str.length();

    for(int i = 0; i < len / 2; i++)  {
        if (str.charAt(i) != str.charAt(len - i - 1))
            return false;
    }
    return true;
}
Posted by: Guest on September-28-2021
0

integer palindrome in java

public boolean isPalindrome(int x) {
        String str = Integer.toString(x);
        String reverse =  new StringBuilder(str).reverse().toString();
        return  str.equals(reverse)?true:false;}
Posted by: Guest on April-26-2021
0

palindrome in java

public class PlaindromeTest1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
System.out.println("Enter your words"); // Whats up body? // ?ydob pu stahW
        String word = input.nextLine();

        String reversedWord = "";
        // start from last index number.
        for(int i = word.length()-1; i>=0; i-- ){
           reversedWord += word.charAt(i);
        }
        System.out.println(reversedWord);
        //Level ==> leveL //ey edip adanada pide ye :)
        boolean palindrome = word.equalsIgnoreCase(reversedWord);

        System.out.println(palindrome);

        String str = "Anna";
        String result = "";

        for(int i = str.length()-1; i>=0; i-- ){
            result += str.substring(i, i+1);
            // result += str.charAt(i); // char at de olur
        }
        boolean result1 = str.equalsIgnoreCase(result);
        System.out.println(result1);
    }
Posted by: Guest on June-04-2021

Code answers related to "palindrome of number in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language