java StringTokenizer - nextToken 可以返回 null 吗?
有没有 StringTokenizer.nextToken 会返回 null 的情况? 我正在尝试在代码中调试 NullPointerException,到目前为止,我发现的唯一可能性是从 nextToken() 返回的字符串返回 null。有这种可能吗?在java文档中没有找到任何内容。
谢谢
Is there any case where StringTokenizer.nextToken will return null?
I'm trying to debug a NullPointerException in my code, and so far the only possibility I've found is that the string returned from nextToken() returned null. Is that a possibility? Didn't find anything in the java doc.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果标记器的字符串中没有更多标记,则 nextToken() 会抛出 NoSuchElementException ;所以我想说它不会返回 null。
http://download.oracle.com /javase/1.4.2/docs/api/java/util/StringTokenizer.html#nextToken()
nextToken() throws NoSuchElementException if there are no more tokens in the tokenizer's string; so I would say that it doesn't return null.
http://download.oracle.com/javase/1.4.2/docs/api/java/util/StringTokenizer.html#nextToken()
我认为它可能会抛出 NullPointerException。
检查nextToken()的代码,
这里,调用skipDelimiters()方法可能会抛出NullPointerException。
I think it can throw a NullPointerException.
Inspecting the code of nextToken(),
Here, invocation of the method skipDelimiters() can throw NullPointerException.