title: how do I solve java.lang.NumberFormatException: Invalid int: "" error in my code?
body: <p>I'm getting the error <code>java.lang.NumberFormatException: Invalid int: ""</code> in my code:</p>
  
  <pre><code>  //breaking up the response into respective parts
    //so we can get values for 'random reviews' string
    try {
      JSONArray responseObject = new JSONArray(response);
  
      //use StringBuilder, so we can append values
      StringBuilder private_review_ids = new StringBuilder();
  
      for (int i = 0; i &lt; responseObject.length(); i++) {
  
        JSONObject obj = responseObject.getJSONObject(i);
  
        //get the "private_review_ids" part of the response, append
        //each value into a string private_review_ids
        private_review_ids.append(obj.getString("private_review_ids").toString());
  
        System.out.println("private_review_ids: " + private_review_ids);
  
    //check that private_review_ids is not 0
    if (private_review_ids.length() != 0){
  
      //make it all into a single string
      String private_review_ids2 = private_review_ids.toString();
  
      //we only want the numbers (the review_ids) so get rid of other stuff
      private_review_ids2 = private_review_ids2.replaceAll("[^0-9]+", ",");
      //get rid of the first ","
      private_review_ids2 = private_review_ids2.replaceFirst(",", "");
  
        System.out.println("private_review_ids2:" + private_review_ids2);
  
      //a string array, separated by commas
      //because we were getting a stray comma at the start
      String[] just_numbers = private_review_ids2.split(",");
  
      //We want 3 random numbers from the array just_numbers
      HashSet&lt;Integer&gt; integers = new HashSet&lt;&gt;(3);
      Random random = new Random();
  
        if (integers != null) {
  
      //get 3 random numbers
      while (integers.size() &lt; 3) {
  
        integers.add(Integer.parseInt(just_numbers[random.nextInt(just_numbers.length)]));
  
      }
  
      //UNDO THIS System.out.println("1. the integers are " + integers);
      System.out.println("1. the integers are " + integers);
  
      //make a string from integers
      random_reviews = integers.toString();
  
      //remove the [ and ] from the string
      random_reviews = random_reviews.substring(1, random_reviews.length() - 1);
      //UNDO THIS System.out.println("2. random_reviews : " + random_reviews);
      System.out.println("2. random_reviews : " + random_reviews);
  
      Toast.makeText(PopulistoListView.this, "random_reviews : " + random_reviews, Toast.LENGTH_LONG).show();
  
    }}
    }catch (JSONException e) {
      Log.e("MYAPP", "unexpected JSON exception", e);
      // Do something to recover ... or kill the app.
    }
  </code></pre>
  
  <p>I've looked at answers here on stackoverflow. As far as I can tell I've heeded advice - using a <code>try catch</code> statement and wrapping it in an <code>if</code> statement but I still get the error on the line</p>
  
  <pre><code>integers.add(Integer.parseInt(just_numbers[random.nextInt(just_numbers.length)]));
  </code></pre>
  
  <p>Any suggestions on how to solve it please?</p>