title: Problems with generics and static methods - Java
body: <p>I'm trying my hand at Generics and implementing a generic list in a simple text based UI, however I keep getting messages saying that I can't get to different methods etc from my methods that are and aren't static.</p>
  
  <p>Can somebody please point out what I am doing wrong?</p>
  
  <pre><code>public class GenericList&lt;T&gt; {
  
      List&lt;T&gt; genericList = new ArrayList&lt;T&gt;();
  
      public void addGeneric(T t) {
          this.genericList.add(t);
      }
  
      public static void initial() {
          // USER INPUT AREA
          switch(ans.toLowerCase()) {
              case "add" : addToList(); break;
              case "delete" : deleteFromList(); break;
              case "print" : printList(); break;
          }
      }
  
      public void deleteFromList() {}
  
      public void printList() {
          for (int i = 0; i&lt;this.genericList.size(); i++) {
              System.out.println(this.genericList.get(i));
          }
      }
  
      public void addToList() {
          // USER INPUT AREA
          switch(type.toLowerCase()) {
              case "x":
                  System.out.println("Exitiing...");
                  initial();
                  break;
              case "string": type="String"; break;
              case "int": type="Integer"; break;
              case "integer": type="Integer"; break;
          }
  
          System.out.println("Enter data...");
          String data = s.next();
          if (data.equals("x")){
              System.out.println("Exiting...");
              initial();
          }
          initial();
  
      }
  
      public static void main(String[] args) {
          GenericList g = new GenericList();
          initial();
  
      }
  }
  </code></pre>