您的位置:首页 > 产品设计 > UI/UE

Java Programming Test Question 2

2016-07-25 15:01 411 查看
public class JPTQuestion2 {
public static void main(String[] args) {
String s3 = "JournalDev";
int start = 1;
char end = 5;
System.out.println(start + end);
System.out.println(s3.substring(start, end));
}
}


注意:这里的end是char类型,可是,输出结果和int型的end没区别。

原因:...........

官方解释:

Java Programming Test Question 2 Answer and Explanation

The given statements output will be ourn. First character will be automatically type caste to int. After that since in java first character index is 0, so it will start from o and print till n. Note that in String substring function it leaves the end index.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: