title: How to concatenate seperate digits from a loop into one single integer
body: <p>okay so I have an assignment that says i have a string of numbers for example 
  "1234 4014 5555 7654" say which is essentially a credit card number. 
  They are asking me to convert the string of digits into single integers then concatenate them into 4 lots of 4 digit integers so the string "1234 4014 555 7654" for example will have 4 blocks 
  block 1 would be 1234 
  which is converted into 1, 2, 3, 4 
  which is then concatenated into 1234 as an integer
  i have to do this for all the blocks... :(</p>
  
  <p>So far.. i made a for loop as shown below :</p>
  
  <pre><code>public static int toInt(String digitString)
  {
      int answer = 0;
      int num = 0;
      for (int j = 0; j &lt; digitString.length(); j++){
          num = (int) digitString.charAt(j) - '0';
          System.out.println(num);
      }
  
      return answer
  </code></pre>
  
  <p>}</p>
  
  <p>and i can successfully convert the string into seperate digits but i have no idea how i can concatenate those digits into 4, 4 digit integers</p>
  
  <p>any help would be much appreciated :)</p>