title: Android code to check condition if variable exits or not from rest api
body: <p>Hi my question is regarding Android programming. I have a varible called <code>company_name</code> which i must fetch from Rest api and print on my Android device. </p>
  
  <p>But my question is i must check for a condition if the <code>company_name</code>(variable) exists or not, if not then it must skip it and print others. </p>
  
  <p>My code:</p>
  
  <pre><code>try {
                      JSONObject jsonObject = new JSONObject(response);
                      final JSONArray jsonArray = jsonObject.getJSONArray("data");
  
  
                      final List&lt;String&gt; names = new ArrayList&lt;String&gt;();
                      for (int i = 0; i &lt; jsonArray.length(); i++) {
                          JSONObject inter = new JSONObject(jsonArray.get(i).toString());
                          ApplyJobItem jobItem = new ApplyJobItem();
                          jobItem.setCompanyName(inter.getString("company_name"));
                          jobItem.setIndustry(inter.getString("industry_selected"));
                          jobItem.setJobPost(inter.getString("title"));
                          jobItem.setJobType(inter.getString("type"));
                          jobItem.setJobId(inter.getString("_id"));
                          //jobItem.setJobCity(inter.getString("location"));
                          //jobItem.setJobSalary(inter.getJSONArray("salary_range").getString(0) + " to " + inter.getJSONArray("salary_range").getString(1));
                          jobItem.setdescription(inter.getString("description"));
                          names.add(inter.getString("company_name"));
                          names.add(inter.getString("industry_selected"));
                          names.add(inter.getString("title"));
                          // names.add(inter.getString("description"));
                          applyJobItems.add(jobItem);
                          android.util.Log.e("Company name", inter.getString("company_name"));
                      }
  
                          ArrayAdapter&lt;String&gt; arrayAdapter = new ArrayAdapter&lt;String&gt;(apply.this, android.R.layout.simple_list_item_2, names);
                          final boolean isCareer = jsonObject.getBoolean("careerUpdated");
                          android.util.Log.e("Entered ", "1");
                          applyJobAdapter = new ApplyJobAdapter(apply.this, applyJobItems, isCareer);
                          android.util.Log.e("Entered ", "2");
                          ListView mylistview = (ListView) findViewById(R.id.list);
                          android.util.Log.e("Entered ", "3");
                          mylistview.setAdapter(applyJobAdapter);
                          android.util.Log.e("Entered ", "4");
  
  
                          mylistview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                              @Override
                              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                                  Intent intent = new Intent(getApplicationContext(), applypage.class);
                                  intent.putExtra("careerUpdate", isCareer);
                                  intent.putExtra("position", position);
                                  startActivity(intent);
                              }
                          });
  </code></pre>