Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Program Discussion :: Basics

Home > Programs > Basics

9 / 248

Can you write a Palidrome program?

Answer:

import java.util.*;

public class strings {
    public static void main(String[] args) {

/*works for both numbers and strings*/
        String str,text1=" ";int s=0,c=0;
        Scanner sc=new Scanner(System.in);
        str=sc.nextLine();
        StringBuilder b = new StringBuilder(str);
        System.out.print(str.equals(b.reverse().toString())?"yes":"no");
    } 
    }
 

Asked In :: Tavant Technologies

Post Your Answer Here:

Language:

Post Your Reply Here: