title: how to use if else in android
body: <p>I am trying to initialize an String array using if else method .. but its not working . How to do it ?</p>
  
  <pre><code>if(itemno==2){
          String[] values = new String[] { "Category31", 
                  "Category32",
                  "Category33",
                  "Category34", 
                  "Category35", 
                  "Category36", 
                  "Category37", 
                  "Android Example List View" ,
                  "daniel",
                  "dude",
                  "hello",
                  "super,","dukker"
  
                 };}
  
  else if(itemno==3){
          String[] values = new String[] { "Category31", 
                  "Category32",
                  "Category33",
                  "Category34", 
                  "Category35", 
                  "Category36", 
                  "Category37", 
                  "Android Example List View" ,
                  "daniel",
                  "dude",
                  "hello",
                  "super,","dukker"
  
                 };}
  
  
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
              android.R.layout.simple_list_item_1, android.R.id.text1, values);
      l.setAdapter(adapter); 
  </code></pre>
  
  <p>but in adapter is showing error that Variable is not accepted.. help me</p>