Java的整個字串的結束索引在最後一個字元之外

FrankYou發表於2016-11-04
/**
 * Created by xfyou on 2016/11/4.
 */
public class SubstringDemo {
    public static void main(String[] args) {
        String a = "Java is great.";
        System.out.println(a);
        System.out.println(a.substring(5));
        System.out.println(a.substring(5, 7));

        // Java的整個字串的結束索引在最後一個字元之外
        System.out.println(a.substring(5, a.length()));

        System.out.println(a.indexOf('.'));
        System.out.println(a.length());
    }
}

 

相關文章