Java StringBuilder reverse() method

reverse(): replace the string builder’s character sequence with the reverse character sequence.

 

Syntax:

public StringBuilder reverse()

 

StringBuilder reverse() Example

class TestStringBuilder{
    StringBuilder sb = 
                new StringBuilder("www.w3schools.blog");
    
    public void reverseTest(){
        //replace the string buffer’s character 
                //sequence by reverse character sequence.
        System.out.println(sb.reverse());
    }
}

public class StringBuilderReverseExample {
    public static void main(String args[]){
        //creating TestStringBuilder object
        TestStringBuilder obj = new TestStringBuilder();
        
        //method call
        obj.reverseTest();
    }
}

Output

moc.063sloohcs3w.www