似乎parseDouble可以接受带有尾随空格的字符串,但是parseInt和parseLong会抛出异常.
例如,对于这个测试用例
@Test
public void testNumberParsing() {
try {
Double.parseDouble("123.0 ");
System.out.println("works");
}catch (NumberFormatException e) {
System.out.println("does not work");
}
try {
Integer.parseInt("123 ");
System.out.println("works");
}catch (NumberFormatException e) {
System.out.println("does not work");
}
try {
Long.parseLong("123 ");
System.out.println("works");
}catch (NumberFormatException e) {
System.out.println("does not work");
}
}
Run Code Online (Sandbox Code Playgroud)
结果是
works
does not work
does not work
Run Code Online (Sandbox Code Playgroud)
为什么行为不同?这是故意的吗?
Kafka更新zookeeper中的状态信息,如下所示._epoch数字究竟意味着什么?Kafka文档似乎没有很好的解释条款.
[zk: localhost:2181(CONNECTED) 69] get /brokers/topics/my-topic/partitions/1/state
{"controller_epoch":29,"leader":2,"version":1,"leader_epoch":28,"isr":[2,1,0]}
Run Code Online (Sandbox Code Playgroud)