title: How can I parse String to int with the default value?
body: <p>I need to parse a string user id into integer for that I used <code>Integer.parseInt(String s)</code> but it returns null/nil, if there string has/holds non-decimal/integer value and in that case, I need to assign default integer value as <code>0</code>.</p>
  
  <p>I tried this but it <code>(? 0)</code> seems not working and I don't know whether it is correct syntax or not.</p>
  
  <pre><code>String userid = "user001";
  int int_userid = Integer.parseInt(userid) ? 0;
  </code></pre>
  
  <p>How can assign default value to integer if there is null assignment?</p>
  
  <p>String userid is a parameter argument as part of web service function call, so I cannot update it's data type to integer.</p>