作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
public static void main(String argv[]){
String a="0700";
Scanner s = new Scanner(a);
while(s.hasNextLong()){
System.out.print(s.nextLong()+",");
}
结果将是“700”,而不是“448”。
最佳答案
默认情况下,扫描器假定数字以 10 为基数,并将忽略前导 0。如果需要,您可以指定另一个基数 - 下面的代码打印 448:
public static void main(String[] args) {
String a = "0700";
Scanner s = new Scanner(a);
while (s.hasNextLong(8)) { //make sure the number can be parsed as an octal
System.out.print(s.nextLong(8)); //read as an octal value
}
}
关于java - 为什么 java.util.Scanner 不能将 0700 视为八进制文字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13647618/
谁能推荐一个好的成员(member)结构? 例如,用户支付了 1 个月的成员(member)费,从 2012 年 2 月 1 日到 2012 年 3 月 1 日结束。 何时何地检查用户是否仍是成员(m
我想在我的 JTextPane 中实现查找机制(如文本编辑器或 word)。我希望它有下一个/上一个选项(向上/向下箭头)并突出显示它找到的所有单词。有没有简单的方法可以做到这一点? 最佳答案 我不是
Android 上是否有任何机制和/或编程实践来执行一次性安装/更新脚本?这似乎是一个非常基本的问题,但谷歌搜索没有帮助。 假设我的应用程序使用了一个数据库,并且需要一个常量值表(例如国家名称、城市名
是否可以将 SimpleMembership 与 ASP.NET WebForms 一起使用? John Galloway 的文章似乎表明 WebForms“在 ASP.NET 成员资格之上实现 OA
我是一名优秀的程序员,十分优秀!