Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class palindrome
- {
- public static void main(String args[])
- {
- StringBuffer sb = new StringBuffer("nitin");
- System.out.println(sb);
- String sb1=sb.reverse();//error coming in this line why ?
- if(sb1.contentEquals(sb))
- {
- System.out.println("palindrome");
- }
- else
- {
- System.out.println("not a palindrome");
- }
- }
- }
- sb.reverse()// This will return a reference to StringBuffer
- sb.reverse().toString()//This will convert it to a String
- sb.reverse().toString()
Add Comment
Please, Sign In to add comment