The output from the following code is 123
because substring
takes from beginIndex to EndIndex - 1. However, I am surprised how char
here is understood as 3 (int) because substring
take two ints. What is the concept behind this?
String x = "12345";
char a = 3;
x = x.substring(0, a);
System.out.println(x);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…