I have this string "5,7,6,1"
and I want to make an integer array of the size 4 like this: out={5 7 6 1}
which out[0]=5
and out[1]=7
and...
actually I want to have the number of the string in an integer array but when I print the out
the output is the address of the array out
like this: [I@152b6651
what's wrong with this code????
public static void main(String[] args) {
String a = new String();
a="5,7,6,1";
int element, temp = 0, ans = 0,j=0;
element = a.length() / 2 + 1;
int[] out = new int[element];
for (int i = 0; i < a.length(); i++) {
if (j < element) {
temp = (int) a.charAt(i);
if (temp != 44) {
ans = ans * 10 + temp;
} else {
out[j] = ans-48;
ans=0;
j++;
}
if(i==a.length()-1){
out[j] = ans-48;
}
}
}
int[] array=new int[element];
System.out.println(out);
}