Computer Science, asked by abedhashimi4158, 1 year ago

How to check a String for palindrome using arrays in java?

Answers

Answered by Sreearjunan
0

Answer:To verify whether the given string is a palindrome (using arrays)

Convert the given string into a character array using the toCharArray() method.

Make a copy of this array.

Reverse the array.

Compare the original array and the reversed array.

in case of match given string is a palindrome.

Answered by nakuldhody2006
0

Answer:

import java.io.* ;

class palindrome  

{

    public static void main () throws IOException

    {

        int num , temp , sum=0 , r=0;

        BufferedReader BR = new BufferedReader(new InputStreamReader( System.in )) ;

        System.out.println("enter any value") ;

        num = Integer.parseInt(BR.readLine()) ;

        temp=num ;

        do

        {  

            int n = temp % 10 ;

            sum = sum*10+ n ;

            temp= temp/10 ;

           }

           while(temp>0 ) ;

           if (num==sum)  

           {

               System.out.println("num " + num + " is a palindrome no ") ;

           }

           else

           {

               System.out.println("num " + num + " is not a palindrome no ") ;}

           }

       }

Explanation:

Copy paste maro or kam khatam karoor koi bhi doubt ho hamse pucho .

Similar questions