“Streichpalindrome in Java” Code-Antworten

Ganzzahl 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;}
Kirk-Patrick Brown

ist 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;
}
Filthy Fox

Ganzzahl 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;
     }
Kirk-Patrick Brown

Streichpalindrome in Java

import java.util.*;
import java.lang.*;
import java.io.*;


 class Main {

    static boolean isPalindrome(String s)
    {

       /* Two pointers initialised to 0 and 's.length()-1'.*/
        int i = 0, j = s.length() - 1;

        /* Looping through the string */
        while (i < j) {

            /* Even if one character is not equal, we will return false. */
            if (s.charAt(i) != s.charAt(j))
                return false;
               
            /* Value of pointers is changed */
            i++;
            j--;
        }
       
        /* This means all characters are same and thus string is a palindrome*/
        return true;
    }

    public static void main(String[] args)
    {
        String s = "abba";

        /* First, We'll convert it to lower case. */
        s = s.toLowerCase();
   
        if (isPalindrome(s))
            System.out.print("Yes");
        else
            System.out.print("No");
    }
}
Coding Ninjas

Palindrome in Java

package com.candidjava; import java.util.Scanner; public class PalindromeUptoN{	public static void main(String[] args)	{		int n, b, rev = 0;		Scanner sc = new Scanner(System.in);		System.out.println("Enter the Palindrome No N:");		int N = sc.nextInt();		System.out.print("Palindrome numbers from 1 to N:");		for (int i = 1; i <= N; i++)		{			n = i;			while (n > 0)			{				b = n % 10;				rev = rev * 10 + b;				n = n / 10;			}			if (rev == i)			{				System.out.print(i + " ");			}			rev = 0;		}	} }
sree_007

Ähnliche Antworten wie “Streichpalindrome in Java”

Fragen ähnlich wie “Streichpalindrome in Java”

Weitere verwandte Antworten zu “Streichpalindrome in Java” auf Java

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen