When i pass this to the constructor: {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
}
}
}
- How do I check that it has been added to
arraylistone
correctly? I want to print out the value of it to make sure I'm on the right track, should i usetoString()
somehow to convert the an array object into aString
? As it sits now it prints out something like this `"[I@72d67791][I@72d67791][I@72d67791]"
"`
- If
(sv == 2)
how would I get theint
value of each individualint
in theString
? For example given theint
12, if I was to divide that into a separatexy = int[]
wherexy[0] =1
andxy[1]=2