StringBuilder str = new StringBuilder("Hello World"); CharSequence subStr = str.subSequence(6, 11); System.out.println(subStr);
StringBuilder str = new StringBuilder("Java is great"); CharSequence subStr = str.subSequence(0, 4); System.out.println(subStr);Output: Java In this example, we created another StringBuilder object with the string "Java is great". We then called the subSequence method to extract a subsequence of the string starting at index 0 and ending at index 4. This returns "Java" which we then printed to the console. The java.lang.StringBuilder subSequence() method is a part of the java.lang package library.