hashtable 的一例:
import java.util.*;
import java.io.*;public class  HashtableD{   public static void main(String[] args){           Hashtable numbers= new Hashtable();           numbers.put("one", new  String("ppp"));
           numbers.put("two", new Integer(2));
           numbers.put("three", new Integer(3));           Integer n = (Integer) numbers.get("two");
           String temp=(String) numbers.get("one");           if(n!=null)
                System.out.println("two="+n);
               System.out.println("one="+temp);
     }
linkedlist 的例子:
import java.util.*;
import java.io.*;public class ListDemo{
     public static void main(String[] args){
          int i=2;
          LinkedList  linklist = new LinkedList();
          linklist.add(new String("first"));
          linklist.add(new Integer("1"));
          linklist.add(new  String("third"));
          linklist.add(i,new String("second"));         
          String firstr=(String)linklist.getFirst();
          String secstr=(String)linklist.get(i);
         
          linklist.remove(2);
    
          String rsec=(String)linklist.get(i);             System.out.println("first="+firstr);
          System.out.println("before remove seconc="+secstr);
          System.out.println("after remove  second="+rsec);
     }
}  上面的例子虽然简单, 但却也实现的hash表和list 的一些基本功能,
}

解决方案 »

  1.   

    能说说HASHTABLE和LIST在什么方面用的比较多,也就是什么时候用这它?
    --是不是有点象数组?
      

  2.   

    谢谢wugng(不妨听听) 还有HashMap,Map
    最好也给个例子
      

  3.   

    还有别的Collection API的都给个例子吧
      

  4.   

    /**
     * @version 1.00 1999-07-07
     * @author Cay Horstmann
     */import java.util.*;public class MapTest
    {  public static void main(String[] args)
       {  Map staff = new HashMap();
          staff.put("144-25-5464", new Employee("Angela Hung"));
          staff.put("567-24-2546", new Employee("Harry Hacker"));
          staff.put("157-62-7935", new Employee("Gary Cooper"));
          staff.put("456-62-5527", new Employee("Francesca Cruz"));      // print all entries      System.out.println(staff);      // remove an entry      staff.remove("567-24-2546");      // replace an entry      staff.put("456-62-5527", new Employee("Francesca Miller"));      // look up a value      System.out.println(staff.get("157-62-7935"));      // iterate through all entries      Set entries = staff.entrySet();
          Iterator iter = entries.iterator();
          while (iter.hasNext())
          {  Map.Entry entry = (Map.Entry)iter.next();
             Object key = entry.getKey();
             Object value = entry.getValue();
             System.out.println("key=" + key + ", value=" + value);
          }
       }
    }class Employee
    {  public Employee(String n)
       {  name = n;
          salary = 0;
       }   public String toString()
       {  return "[name=" + name + ", salary=" + salary + "]";
       }   public void setSalary(double s)
       {  salary = s;
       }   private String name;
       private double salary;
    }
      

  5.   

    谢谢xmvigour(微电)
    待会儿给分,给出例子的都有