title: For loop - how to?
body: <p>I am trying to run the following code in Android but there seems to be some problem with the for loop. The code builds without any build error but when I try access the second element of the array station_id it gives a runtime error. If I try to access station_id[0], then there is no error at all. I was not sure if the for loop actually loops over and stores the data in every element of the array. Therefore I tried printing the value of i to check if the for loop runs 187 times. However, 'i' is printed only once in the logcat of Android studio. I could not figure out where it goes wrong. Your suggestions would be of great help. Below is my code.</p>
  
  <pre><code>public class LoadDataOnce {
      private String Url_get_data;
      private String result_fullData;
      private JSONArray fullData;
      // GetData - class that sends http get request and fetches data
      private GetData getfullData;
      private String [] station_id;
      private String []  station_coordinates;
      private int total_num_of_stations;
  
  public LoadDataOnce() {
      Url_get_data = "http://fluggs.wupperverband.de/sos2/api/v1/timeseries/";
      result_fullData = null;
      fullData = null;
      getfullData = new GetData();
      station_id = new String[187];
      station_coordinates = new String[187];
      total_num_of_stations = 0;
  }
  
  
  public String[] getStation_id() {
  
      return station_id;
  
  }
  
  
  
  public String [] getStation_coordinates() {
      return station_coordinates;
  }
  
  
  
  public int getTotal_num_of_stations() {
      return total_num_of_stations;
  }
  
  
  
  
  public void loadData () {
  
      try {
          result_fullData = getfullData.execute(Url_get_data).get();
  
          try {
              fullData = new JSONArray(result_fullData);
              total_num_of_stations = fullData.length();
              //station_id =  new String [total_num_of_stations];
              station_coordinates = new String[total_num_of_stations];
              for (int i = 0; i &lt; 187; i++){
                  station_id[i] = fullData.getJSONObject(i).getJSONObject("station").getJSONObject("properties").getString("id");
                  System.out.println(i);
                  station_coordinates[i] = fullData.getJSONObject(i).getJSONObject("geometry").getString("coordinates");
              }
          } catch (JSONException e) {
              e.printStackTrace();
          }
      } catch (InterruptedException e) {
          e.printStackTrace();
      } catch (ExecutionException e) {
          e.printStackTrace();
      }
  }
  
  
  }
  </code></pre>
  
  <p>Exception that I get while testing in Android 7.0 phone. <br>
  <br></p>
  
  <pre><code>    java.lang.RuntimeException: Unable to start activity 
      ComponentInfo{com.example.charu.droidar_wupperverband/system.ArActivity}: 
      java.lang.IllegalArgumentException: width and height must be &gt; 0
      at 
      android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2924)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985)
      at android.app.ActivityThread.-wrap14(ActivityThread.java)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:154)
      at android.app.ActivityThread.main(ActivityThread.java:6692)
      at java.lang.reflect.Method.invoke(Native Method)
      at 
  
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
  Caused by: java.lang.IllegalArgumentException: width and height must be &gt; 0
      at android.graphics.Bitmap.createBitmap(Bitmap.java:969)
      at android.graphics.Bitmap.createBitmap(Bitmap.java:948)
      at android.graphics.Bitmap.createBitmap(Bitmap.java:915)
      at util.IO.loadBitmapFromView(IO.java:158)
      at util.IO.loadBitmapFromView(IO.java:140)
      at gl.GLFactory.newTextObject(GLFactory.java:611)
      at com.example.charu.droidar_wupperverband.WupperAugment._b_addWorldsToRenderer(WupperAugment.java:106)
      at system.Setup.run(Setup.java:254)
      at system.ArActivity.runSetup(ArActivity.java:61)
      at system.ArActivity.onCreate(ArActivity.java:38)
      at android.app.Activity.performCreate(Activity.java:6912)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2877)
      ... 9 more
  
  
   &lt;Debug Infos&gt;
   OS Version: 3.18.14-12365438 (G930FXXU1DQJ8)
   OS API Level: 24
   Device: herolte
   Model (and Product): SM-G930F (heroltexx)
   Manufacturer: samsung
   Other TAGS: release-keys
   screenWidth: 1080
   screenHeigth: 1920
   Keyboard available: false
   Trackball available: false
   SD Card state: mounted 
  </code></pre>