title: How can I use Lambda to convert a String array to Integer array?
body: <p>I am trying to use lambda expressions to convert a String array to an Integer array.</p>
  
  <p>I have provided my code below, along with a brief description of what I have tried so far:</p>
  
  <pre><code>String [] inputData = userInput.split("\\s+");
  Integer [] toSort = new Integer [] {};
  try {
      toSort = Arrays.asList(inputData).stream().mapToInt(Integer::parseInt).toArray();
  }catch(NumberFormatException e) {
      System.out.println("Error. Invalid input!\n" + e.getMessage());
  }
  </code></pre>
  
  <p>The lamba expression I have above is one which maps to an int array, which is not what I want, upon compiling this code I get the following error message:</p>
  
  <pre><code>BubbleSort.java:13: error: incompatible types: int[] cannot be converted to Integer[]
              toSort = Arrays.asList(inputData).stream().mapToInt(Integer::parseIn
  t).toArray();
  
            ^
  1 error
  </code></pre>
  
  <p>Is there a simple way which allows me to use lambdas, or other means, to get from a String array to an Integer array?</p>