title: Integer vs. String decision making in Java
body: <p>I'm working on a program where user input is an array of mixed Strings and Integers. For Example: </p>
  
  <p>dog 10 23 cat frog 22 elephant</p>
  
  <p>I'm supposed to sort this array without changing the type of each index. So the output  will be; </p>
  
  <p>cat 10 22 dog elephant 23 frog</p>
  
  <p>After reading the line from the console, I'm using a string tokenizer to go through each element. After that I'm trying to parseInt and if it throws an exception, I'm assuming that it is a string, otherwise it is an Integer. Is there a better way to figure out if a token is numerical or not?</p>
  
  <p>Thank you.</p>