在ArrayList add()中插入09时出错? [英] error while inserting 09 in ArrayList add()?
本文介绍了在ArrayList add()中插入09时出错?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
i尝试在我的ArrayList的add方法中插入09时有一个错误如何解决它
当我google for it它给我解决方案就像它的八进制不,我需要将这个变为十进制否
我该怎么做请任何人帮助我...
import java.util。*;
class MyArrayList {
public static void main( String args []){
ArrayList al = new数组列表();
al.add( new 整数( 09 ));
System.out.println(al);
}
}
< br />
输出: MyArrayList.java:5:error整数太大:09< br />
解决方案
正如已经告诉过你的那样,整数文字从零开始被视为具有八进制
base(并且,您知道,八进制数的允许数字是{0,1,2,3,4, 5,6,7}
)。如果您需要将十进制
9
添加到ArrayList,则必须删除标题'0
',改变自
Quote:al.add(new整数(09));
到
al.add( new 整数( 9 跨度>));
hello
i have an error while trying to insert 09 in my ArrayList's add method how to resolve it
when i google for it its give me solution like its a octal no and i need to chage this to decimal no
how do i do this please any one help me ...
import java.util.*;
class MyArrayList{
public static void main(String args[]){
ArrayList al=new ArrayList();
al.add(new Integer(09));
System.out.println(al);
}
}
<br /> output:MyArrayList.java:5:error integer too large:09<br />
解决方案
As have been already told to you, integer literals starting with zero are considered havingoctal
base (and, you know, allowed digit of octal base are{0,1,2,3,4,5,6,7}
). If you need to add thedecimal
9
to the ArrayList then you have to remove the heading '0
', that is change from
Quote:al.add(new Integer(09));
to
al.add(new Integer(9));
这篇关于在ArrayList add()中插入09时出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文