//palindrome Example - Save this program as "palindrome.java"
class pa
{
public boolean mtd(String str)
{
int left=0 ;
int right = str.length()-1;
while ( left < right)
{
if(str.charAt(left) != str.charAt(right))
{
return false;
}
left++;
right--;
}
return true;
}
}
public class palindrome {
public static void main(String args[])
{
pa obj = new pa();
System.out.print("-->"+obj.mtd("madam"));
}
}
No comments:
Post a Comment