title: continue in for loop causes nullpointerexception for ArrayList
body: <p>I have the following function to perform normalization operation of some data.</p>
  <pre><code>public static void normalization(NormalizedData dataObject) {
          // Create new arraylist&lt;String&gt; to store the normalized values.
          ArrayList&lt;String&gt; normalizedValues = new ArrayList&lt;&gt;();
          // init variables.
          double normalizedValue =0;
          int attributeValue = 0;
          // Get the minimum and maximum attribute values, and the attribute type.
          int minimumValue = dataObject.getMinimumAttributeValue();
          int maximumValue = dataObject.getMaximumAttributeValue();
          String dataAttributeType = dataObject.getDataAttributeType();
          // Iterate through the individual strings.
          for (String attribute:dataObject.getData()) {
              if (maximumValue == minimumValue) {
                  continue;
              }
              else if (maximumValue &lt;=1) {
                  normalizedValues.add(attribute);
              }
              // Check if the attribute is numerical to perform normalization operation.
               else if (dataAttributeType.equals(&quot;n&quot;)) {
                  // Cast string to integer.
                  attributeValue = Integer.parseInt(attribute);
                  // Normalization operation on integers, cast to double.
                  normalizedValue = (double) (attributeValue - minimumValue) / (maximumValue - minimumValue);
                  // Add the string value of the normalization operation to the new arraylist, format to 3 decimal places.
                  normalizedValues.add(String.format(&quot;%.3f&quot;,normalizedValue));
              }
              // Else if the attribute is categorical, just add to the list without any operation.
              else if (dataAttributeType.equals(&quot;c&quot;)) {
                  normalizedValues.add(attribute);
              }
              // Add the newly created arraylist of normalizedValues to the dataObject.
              dataObject.setNormalizedValues(normalizedValues);
          }
      }
  </code></pre>
  <p>The function is called in a for loop to iterate through an ArrayList of objects.</p>
  <pre><code>for (NormalizedData dataObject:normalizedDataObjectArrayList) {
          normalization(dataObject);
      }
  </code></pre>
  <p>If the minimum and maximum attribute values of the data object are the same, the current iteration should be skipped. When trying to do this comparing the min max and having a continue statement, no values are ever added to the dataObject, and when the next block of code is executed to write the ArrayList of normalized values from the Data Object to a .txt file, I get the following error.</p>
  <pre><code>Exception in thread &quot;main&quot; java.lang.NullPointerException: Cannot invoke &quot;java.util.List.get(int)&quot; because &quot;stringArrayList&quot; is null
      at Normalization.buildData(Normalization.java:129)
      at Normalization.generateNormalizedData(Normalization.java:72)
      at Task1.mainMenu(Task1.java:46)
      at Task1.main(Task1.java:22)
  </code></pre>
  <p>The actual breakpoint occurs when trying to then build a string to write to a .txt file with this function.</p>
  <pre><code> public static String buildData(ArrayList&lt;NormalizedData&gt; arrayList) {
          StringBuilder stringBuilder = new StringBuilder();
          // Init counter.
          int i = 0;
          // Do while loop
          do {
              // Iterate through each dataObject in the ArrayList
              for (NormalizedData dataObject : arrayList) {
                  // Create a list of strings for the data of the current object.
                  List&lt;String&gt; stringArrayList = dataObject.getNormalizedValues();
                  // Append the string at index i for the current data object.
                  stringBuilder.append(stringArrayList.get(i)).append(&quot; &quot;);
              }
              // Add a new line.
              stringBuilder.append(&quot;\n&quot;);
              // Increase counter.
              i++;
          }
          // Loop through entire arrayList size.
          while (i &lt;= arrayList.size());
          // Return string that was created, ready to write to file.
          return String.valueOf(stringBuilder);
      }
  </code></pre>
  <p>This breakpoint only occurs when I try to skip iterations where the maximum and minimum attributes are the same by adding the following to the normalization function. It seems trying to skip an iteration in the for loop somehow results in the ArrayList being null.</p>
  <pre><code> if (maximumValue == minimumValue) {
                  continue;
              }
  </code></pre>
  <p>Everything works as intended until I try to do this check.</p>