how do i convert a given string of numbers into an integer?
String numStr = "173 2643 123 1 6";
String numStr = "173 2643 123 1 6"; // First we split it into an array String[] numStrArray = numStr.split(" "); // What this does is makes numStrArray be: // {"173", "2643", "123", "1", "6"} // Now we need to go through the array, // converting the strings to ints: int len = numStrArray.length; int[] numArray = new int[len]; for(int i = 0; i < len; i++) { String val = numStrArray[i] numArray[i] = Integer.parseInt(val); } // Now numArray is: // {173, 2643, 123, 1, 6}