string中字符索引的問題
public class StringIndex {
public static void main(String[] args){
String word="we are the champion";//定義字符串
System.out.println("we are the champion的奇數(shù)字符索引為:");
for(int i=0;i<word.length();i++){
if(i%2==1){
System.out.print(word.charAt(i)+" ");
}
}
}
}
為什么運行后結果中字符串中的w不 是奇數(shù)索引的
2015-11-23
w的角標是0.。。這是奇數(shù)嗎。。。