Convert String Array to int Array
Java Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import java.util.Arrays; class Main { public static void main(String[] args) { String [] str = {"123", "345", "437", "894"}; int size = str.length; int [] arr = new int [size]; for(int i=0; i<size; i++) { arr[i] = Integer.parseInt(str[i]); } for (int var : arr) { System.out.printf( "num = %d\n", var); } } } |
Output: