⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 java2应用开发指南第一版
💻 JAVA
字号:
import java.util.*;

class Main
{
    public static void main(String[] args)
{
        Hashtable h = new Hashtable();
        h.put("dog", "spot");
        h.put("cat", "luck");
        h.put("cow", "spot");
        h.put("yak", "spot");
        Collection col = h.values();
	    // [luck, spot, spot, spot, ]
        printCol( col );                     
        // true
        System.out.println( col.contains("spot") );  

        // remove() removes one entry from the h.
        col.remove("spot");
        // {cat=luck, cow=spot, yak=spot}
        System.out.println( h );             
        // removeAll() removes all entries with the value "spot".
        col.removeAll(Collections.singleton("spot"));
        // {cat=luck}
        System.out.println( h );             
        // Add to the h and check the collection
        h.put("dog", "spot");
        // [luck, spot, ]
        printCol( col );                     
        // You can't add to the collection.
        //col.add("bess");                   
// UnsupportedOperationException
    }

    static void printCol(Collection c) 
	{
        System.out.print("[");
        for (Iterator it=c.iterator(); it.hasNext(); )
		{
            System.out.print(it.next()+", ");
        }
        System.out.println("]");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -