WHAT'S NEW?

Palindrome only using String functions

PalindromeWithString.java


class PalindromeWithString 
{
public static void main(String[] args) 
{
String str="dad";

String rev="";

int l=str.length();

for (int i=l-1;i>=0 ;i-- )
{
rev=rev+str.charAt(i);
}

if (str.equals(rev))
{
System.out.println("String is a Palindrome");
}
else
{
System.out.println("String is not a Palindrome");
}
}
}

0 comments:

Post a Comment