programme:- to show that the word we taken from user is palindrome or not
public class string2
{
public static void main(String args[])
{
String s1,s2;
s1=new String(args[0]);
s2=new StringBuffer(s1).reverse().toString();
if(s1.equals(s2))
{
System.out.println("The word is palindrome");
}
else
{
System.out.println("not palindrome");
}
}
}
The word palindrome means that the word is equal from both the ends
ex:MADAM
to use this
1) go to cmd
2) javac string2.java
3) java string MADAM
public class string2
{
public static void main(String args[])
{
String s1,s2;
s1=new String(args[0]);
s2=new StringBuffer(s1).reverse().toString();
if(s1.equals(s2))
{
System.out.println("The word is palindrome");
}
else
{
System.out.println("not palindrome");
}
}
}
The word palindrome means that the word is equal from both the ends
ex:MADAM
to use this
1) go to cmd
2) javac string2.java
3) java string MADAM
No comments:
Post a Comment