![](/img/trans.png)
[英]What is the meaning of the spin in the getAndIncrement method in the AtomicInteger class?
[英]what is the meaning of arguments in substring method of String class
class Test {
public static void main(String[] args) {
String str="Hello world";
System.out.println(str.substring(0, 4));
}
}
為什么輸出不是 Hello ? 如果子字符串方法的參數分別指示起點和終點。 這里從 0 索引開始,為什么它在索引 4 之前結束。我的意思是為什么這里沒有打印索引 4 字符
str.substring(0, 4)
從索引0
包括索引0
到索引4
不包括檢索給定str
一部分。 結果是Hell
。
String
類的 Java 文檔: public CharSequence subSequence(int beginIndex, int endIndex)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.