How to copy part of a string from StringBuilder to String in Java

1 Answer

0 votes
package javaapplication1;

import java.io.IOException;

public class JavaApplication1 {

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

        StringBuilder builder = new StringBuilder("java c c++ python");

        String s1 = builder.substring(5);
        System.out.println(s1);

        String s2 = builder.substring(0, 4);
        System.out.println(s2);
    }
}


/*

run:
                   
c c++ python
java
          
 */

 



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

Related questions

...