“String palindrome di java” Kode Jawaban

Integer Palindrome di 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

adalah 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

Integer Palindrome di 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

String palindrome di 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 di 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

Jawaban yang mirip dengan “String palindrome di java”

Pertanyaan yang mirip dengan “String palindrome di java”

Lebih banyak jawaban terkait untuk “String palindrome di java” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya