title: How to stop endless loop when calling and writing an array from a static method
body: <p>Java Novice:</p>
  
  <p>I am practicing this stuff: How do I stop the endless loop when calling the array from the method into the main method?</p>
  
  <pre><code>public static String[] ArrayColors() {
      String MyColors[] = { "Red", "Blue", "Green"};
      return MyColors;
  }
  
  public static String WriteArray() {
      for (int i = 0; i &lt; 2; i++) {
          for (String lines : ArrayColors()) {
  
              switch (i) {
              case 0:
                  lines = lines.replace("Red", "Blood");
                  break;
              case 1:
                  lines = lines.replace("Blue", "Ocean");
                  break;
              case 2:
                  lines = lines.replace("Green", "Giant");
                  break;
              }
  
              System.out.println(lines);
          }
          System.out.println();
      }
      return WriteArray().toString();
  }
  
  public static void main(String[] args) {
      System.out.println(WriteArray());
  }
  </code></pre>