Java中的字符串是否基于零索引?
String fullName = "Bill Gates";
String a = fullName.substring(0,2);
System.out.println(a);
输出:双
我尝试了上面的代码并且输出是“Bi”,所以根据输出字符串存储带有索引1,2,3的字符......
答案 0 :(得分:1)
java中的字符串就像数组一样。索引从0开始。我认为你对API很困惑,substring(0,2)从索引0开始的字符串返回2个字符。请参考https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#substring(int,%20int)
答案 1 :(得分:0)
This应该让您了解2017-04-27 08:52:12,068 INFO [stdout] (MSC service thread 1-8) 27.04.2017 08:52:12.068 [MSC service thread 1-8] INFO x.y.b.s.ScheduleServletListener#contextInitialized(70) - Initializing the servlet context...
2017-04-27 08:52:12,068 INFO [stdout] (MSC service thread 1-8) 27.04.2017 08:52:12.068 [MSC service thread 1-8] INFO xx.yyy.blah.something.JNDIUtil#getProxyHost(145) - java:/app_proxyhost: 10.10.10.10
2017-04-27 08:52:12,068 INFO [stdout] (MSC service thread 1-8) 27.04.2017 08:52:12.068 [MSC service thread 1-8] DEBUG xx.yyy.blah.something.ProxyUtils#setProxy(30) - ProxyHost: 10.10.10.10
实际上是如何运作的。