当我将它传递给构造函数时:{12,1,3,22,0,4}
public class Test
{
private ArrayList<int[]> arraylistone;
public Test(int[] ab) //todo
{
int[] xy = new int[2];
arraylistone = new ArrayList<int[]>(ab.length);
for(int i=0; i < ab.length; i++){
int sv = String.valueOf(ab[i]).length();
if (sv == 1){
xy[0] = 0;
xy[1] = ab[i];
arraylistone.add(xy);
}
else if(sv == 2){
//TODO
}
else{
System.out.println("errormessage");
//throw argument "too many digits..."
}
System.out.println(arraylistone); // want to check that the array list ab has been added converterted into two single digit numbers (xy) and stored in arraylistone
}
}
}
- 如何检查它是否已
arraylistone
正确添加?我想打印出它的值以确保我在正确的轨道上,我应该toString()
以某种方式将数组对象转换为String
? 现在它会打印出类似这样的内容 `"[I@72d67791][I@72d67791][I@72d67791]"
"`
- 如果
(sv == 2)
我将如何获得int
每个人int
的价值String
?例如给定int
12,如果我要将它分成单独的xy = int[]
wherexy[0] =1
和xy[1]=2