コード例 #1
0
  public static void main(String[] args) {
    MyLinkedList list = new MyLinkedList();
    list.add(0, 7);
    list.add(8);
    list.add(10);
    list.add(2, 9);
    list.add(4, 11);

    System.out.println("--------------------------");
    System.out.println("size: " + list.size());
    showList(list);

    list.remove(3);
    System.out.println("--------------------------");
    System.out.println("list.remove(3);");
    System.out.println("size: " + list.size());
    showList(list);

    System.out.println("--------------------------");
    System.out.println("list.set(2, 999);");
    System.out.println("size: " + list.size());
    list.set(2, 999);
    showList(list);
  }
コード例 #2
0
 public static void showList(MyLinkedList list) {
   for (int i = 0; i < list.size(); i++) {
     System.out.println(list.get(i));
   }
 }