Tuesday, 24 March 2015

Filled Under:

How To Reverse String In Java

There are many situation where we need to reverse the string there are many methods to do this but these methods are very complex to apply StringBuffer provides simple method its shown below
StringBuffer reverse()

CODING:

class reverse
{

public static void main(String args[])

{

StringBuffer sb = new StringBuffer("fedcba");

System.out.println("Before Reverse : "+sb);
sb.reverse();
System.out.println("After Reverse : "+sb);

}

}

OUTPUT:



0 comments:

Post a Comment