java - String to Array Int -


write function takes number represented string argument, example "12345" or "4321432143214321" , returns digits of number in array.

your function should create int[] array 1 digit of number per element.

can please hint how can approach problem?

public int[] converttoarray(string str){     int array[] = new int[str.length()];     for(int = 0; < array.length; i++){        try{            array[i] = integer.parseint(str.substring(i,i+1));        }catch(numberformatexception e){            e.printstacktrace();            array[i] = 0;        }     }     return array; } 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -