a = "123,456,789";
b = a.split(",");
c = [];
for (var i = 0; i < b.length; i++) {
c.push(Number.parseInt(b[i]));
}
console.log(c);
public static void main(String[] args) throws Exception {
String str="12345";
int arr[] = new int[str.length()];
for (int i = 0;i < str.length(); i ++)
{
arr[i] = Integer.parseInt(str.substring(i,i+1));
System.out.println(arr[i]);
}
}