title: How to create a method that returns an ArrayList
body: <p>From reading tutorials and practicing Java, I have come across a problem. I have created a String ArrayList, added string to it. However I want one method which allows me to add more string to this arrayList and another method which allows me to display this arrayList. below is my attempt to solve this problem. My code only prints an empty Array List</p>
  
  <pre><code>class apples {
      public static void main(String[] args) {
          viewArrayList(); //prints a empty arraylist
      }
  
      public static void addString() {
          ArrayList&lt;String&gt; destinationArray = new ArrayList&lt;String&gt;();
          destinationArray.add("example1");
          destinationArray.add("example2");
      }
  
      static ArrayList GetArrayList() {
          ArrayList&lt;String&gt; destinationArray = new ArrayList&lt;String&gt;();
  
          return destinationArray;
      }
  
      public static void viewArrayList() {
          System.out.println(GetArrayList());
      }
  }
  </code></pre>