Outline how a Java program could convert a string such as “1,2,3,4,5” into an array ({1, 2, 3, 4,5})
Try this:
String[] array = "1,2,3,4,5".split(","); int[] result = new result[array.length]; for (int i = 0; i < array.length; i++) { try { result[i] = Integer.parseInt(array[i]); } catch (NumberFormatException nfe) {}; }