title: How can I make if-else work properly in my try-catch statement?
body: <p>I have a <code>json array</code> of all names and contacts on my phone, looks something like this:</p>
  
  <pre><code>[{"name":"andy","phone_number":"+123"},{"name":"bob","phone_number":"+456"},{"name":"chris","phone_number":"+789"}]
  </code></pre>
  
  <p>I check the phone numbers against phone numbers in a db, if there's a match I want to show the name in the recycler view, if no match, then show just the number.</p>
  
  <p>For example, <code>+123</code>, yes, it is in the db, so show <code>andy</code> in the cell in <code>recyclerview</code>. <code>+789</code> is not in the db, so show <code>+789</code> in the cell.</p>
  
  <p>Here's what I'm working with so far: it works when there is a match, the <code>if</code> part, but I don't know how to deal with the <code>else</code> part (for when there is no match). If I uncomment my <code>else</code> code it always jumps straight to there.</p>
  
  <pre><code>    public void onResponse(String response) {
  
      try {
  
        //name our JSONObject User_Private_Public_Obj, which is response from server
        //the response from server will be like:
        //{"private_review_ids":[{"reviewid":7,"username":"+123"},{"reviewid":14,"username":"+456"}]}
  
        JSONObject User_Private_Public_Obj = new JSONObject(response);
  
        //Now break up the response from server
        //We want the JSON Array part, "private_review_ids"
        JSONArray private_ids = User_Private_Public_Obj.getJSONArray("private_review_ids");
  
        for
          //get the number of objects in User_Private_Public_Obj
            (int i = 0; i &lt; private_ids.length(); i++)
  
        {
  
          //for each object in the array private_ids, name it obj
          //each obj will consist of reviewid and username
          JSONObject obj = private_ids.getJSONObject(i);
  
          Review review = new Review();
  
          //get the string from sharedpreferences, AllPhonesandNamesofContacts,
          //it will be like [{"phone_number":"+123","name":"andy"}, etc...]
          //we want this so we can display phone name in recyclerView, if it's a contact
          SharedPreferences sharedPrefs = getSharedPreferences("MyData", Context.MODE_PRIVATE);
          String json_array = sharedPrefs.getString("AllPhonesandNamesofContacts", "0");
  
          //convert the string above into a json array
          JSONArray jsonArray = new JSONArray(json_array);
  
        //set a string to the phone number from the DB,
          //the phone number of the person who made the review
          phoneNoInDB = obj.getString("username");
  
          //set the setter to the phone number string, the string is
          //the phone number of the person who made the review
          review.setPhoneNumberofUserFromDB(phoneNoInDB);
  
          //jsonArray is our All Phones and Names of Contacts array
          int matching = jsonArray.length();
  
          for (int n = 0; n &lt; matching; n++) {
  
            try {
  
              //for every object in "All Phones and Names of Contacts" array...
              JSONObject object = jsonArray.getJSONObject(n);
  
              //if the review maker is a contact...that is,
              //if the phone_number in AllPhonesandNamesofContacts equals
              //the phone number in the DB
              if (object.getString("phone_number").equals(phoneNoInDB)) {
  
               //just for testing purposes...
                Toast.makeText(NewActivity.this, object.getString("phone_number") + " = " + phoneNoInDB, Toast.LENGTH_LONG).show();
  
                //then rip out the other part of the object, the name in
                // AllPhonesandNamesofContacts
                //of the person who made the review
                review.setphoneNameonPhone(object.getString("name"));
  
                //add the review to the sharedReviewList
                reviewList.add(review);
  
              }
  
            /*  else {
  
                  //just for testing...
                  Toast.makeText(NewActivity.this, " should be green" + object.getString("phone_number") + " = " + phoneNoInDB, Toast.LENGTH_LONG).show();
  
                  review.setphoneNameonPhone(object.getString("phone_number"));
  
                  //add the review to the sharedReviewList
                  //reviewList.add(review);
  
                }*/
  
  
            } catch (JSONException e) {
              System.out.println("error in if else");
              //Log.e("MYAPP", "unexpected JSON exception", e);
              // Do something to recover ... or kill the app.
            }
          }
  
        //set the adapter to show the random reviews
        recyclerView.setAdapter(uAdapter);
  </code></pre>