String string has to be intercepted substring operation

 public static void main(String[] args) {
    
    
        String x="abcdefg";
        System.out.println(x.length());
        // 0到3号位置
        String zero = x.substring(0, 3);
        // 3号位置以后默认所有
        String one = x.substring(3);
        //3号位置以后,可以写 x.length 不可越界
        String two = x.substring(3,x.length());
    

        System.out.println(zero);
        System.out.println(one);
        System.out.println(two);
    }

Guess you like

Origin blog.csdn.net/weixin_43689953/article/details/109683298