Java string truncation

Time:2020-4-6
import org.apache.commons.lang.StringUtils;

public class substr{
    public static void main(String[] args) {
        String str = "1234567890ABCDEFG";
        System. Out. Println ("-----------" + str.substring (0)); // intercept from the string index of 0 to the end of the string
        System. Out. Println ("------ 1 ------" + str.substring (6,7)); // from index 6 to index 7 (index 7 is not included, but "7" is actually intercepted)
        System.out.println("-----2------" + str.substring(str.length()-3, str.length()-1));
        System.out.println("-----3------" + str.substring(0, str.indexOf("4")));
        System.out.println("-----4------" + str.substring(str.indexOf("4") + 1, str.length()));
        System.out.println("-----5------" + str.substring(str.indexOf("4"), str.indexOf("F")));

        String strs = "0899991003535197";
        System.out.println("===========" + strs.substring(6, strs.length()));
        System.out.println("=====1======" + strs.substring(0, 2));
        System.out.println("=====2======" + StringUtils.substringBefore(strs, "3"));
        System.out.println("=====3======" + StringUtils.substringBeforeLast(strs, "3"));
        System.out.println("=====4======" + StringUtils.substringAfter(strs, "3"));
        System.out.println("=====5======" + StringUtils.substringAfterLast(strs, "3"));

        String str1 = "as,asd,df,asd,efd,asd";
        String [] list1 = str1.split(",");
        for(int i=0;i<list1.length;i++)
        {
            System. Out. Println ("the" + (I + 1) + "elements are:" + LIST1 [i]);
        }
    }
}

Operation result:
———–1234567890ABCDEFG
—–1——7
—–2——EF
—–3——123
—–4——567890ABCDEFG
—–5——4567890ABCDE
===========1003535197
=====1======08
=====2======089999100
=====3======08999910035
=====4======535197
=====5======5197
The first element is: as
The second element is: ASD
The third element is: DF
The fourth element is: ASD
The fifth element is: EFD
The sixth element is: ASD