How to reduce the number of characters of a StringBuilder() in Java

1 Answer

0 votes
package javaapplication1;

import java.io.IOException;

public class JavaApplication1 {

    public static void main(String[] args) throws IOException {

        StringBuilder sb = new StringBuilder("java c c++ c#");
        
        sb.setLength(6);
        
        System.out.println(sb);
    }
}


/*

run:
                   
java c
          
 */

 



answered Dec 19, 2016 by avibootz
edited Jan 10, 2017 by avibootz

Related questions

1 answer 105 views
1 answer 225 views
1 answer 131 views
1 answer 133 views
1 answer 162 views
1 answer 145 views
...