Wednesday 9 July 2014

reverse()

public synchronized StringBuffer reverse()
Causes this character sequence to be replaced by the reverse of the sequence. If there are any surrogate pairs included in the sequence, these are treated as single characters for the reverse operation.

public class StringBfferReverse {
    public static void main(String args[]){
        StringBuffer s1 = new StringBuffer("Reverse Me");
        
        System.out.println("Before calling reverse method s1 = " + s1);
        s1.reverse();
        System.out.println("After calling reverse method s1 = " + s1);
    }
}

Output
Before calling reverse method s1 = Reverse Me
After calling reverse method s1 = eM esreveR



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment