[Solved] convert string array into integer array android [closed]


Because Integer.parseInt(urls[i]); is throwing NumberFormatException and you are swallowing the Exception . The below code will not work in your case, but at least you will get to know the error:

try{
     a[i]=Integer.parseInt(urls[i]);
   }catch(Exception e){
     e.printStackTrace();
     throw new RunTimeException(e);
 }

All the elements of a primitive int array are defaulted to 0. Hence you get the 0s .

You cannot parse string like "http://yui.kl.png" etc to int as they are not in numeric format . Read the documentation:

Throws:

NumberFormatException – if the string does not contain a parsable integer.

solved convert string array into integer array android [closed]