title: implementing list using arrays
body: <p>I'm trying to implement list using arrays and generics. I'm stuck up on how to insert values into the generic list. Scanner's nextXXX variants expect a specific type but we know the type only at run time.</p>
  
  <pre><code>class Arraylist&lt;T&gt;
  {
      static Scanner input = new Scanner(System.in);
      static T list[];
      static int top = -1;
  
      public static void displaymenu()
      {
          int choice;
          do {
              // get choice from user
              switch (choice) {
              case 1:
                  list = createlist();
                  break;
              case 2:
                  insertnode();
                  break;
              // ........
              }
          } while (true);
      }
  
      public static Object[] createlist()
      {
          list = new T[LIST_SIZE];
          return list;
      }
  
      public static void insertnode()
      {
          T o;
          top++;
          out.println("Enter the value to insert:");
          // o = user's input. I'm confused here???
      }
  }
  </code></pre>
  
  <p>Thank you.</p>