CODE
class StringReverseExample
{
public static void main(String arg[])
{
StringBuffer firstWord = new StringBuffer("Hello World");
System.out.println(firstWord);
firstWord.reverse();
System.out.println(firstWord);
}
}
Hello World
dlroW olleH
This program shows how to reverse
the contents within StringBuffer
object firstWord
. The first output line Hello World is just the display of the contents of firstWord
. Then reverse()
is used to reverse the contents of firstWord
, so the second output dlroW olleH is the result of it.
madam
", "window
". Show that the above mentioned strings are palindromes.