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

📄 example68hashapp.txt

📁 几个简单的java学习代码
💻 TXT
字号:
import java.util.*;

public class HashApp {

 public static void main(String[] args)  {

    Hashtable h= new Hashtable();
    h.put("height","6 feet" );
    h.put("weight","200 pounds");
    h.put("color","yellow");

    System.out.println("h:" + h);

    Enumeration e = h.keys();
    System.out.print("keys: ");
    while(e.hasMoreElements())
      System.out.print(e.nextElement()+",  ");

    System.out.print("\nelements: ");
    e = h.elements() ;
     while(e.hasMoreElements())
      System.out.print(e.nextElement()+", ");
    System.out.println();

    System.out.println("height: " +h.get("height"));
    System.out.println("weight: " +h.get("weight"));
    System.out.println("color: " +h.get("color"));

    h.remove("height");
    System.out.println("h:" + h);


 }
}


运行结果:

h:{height=6 feet, color=yellow, weight=200 pounds}keys: height,  color,  weight,  
elements: 6 feet, yellow, 200 pounds, height: 6 feetweight: 200 poundscolor: yellowh:{color=yellow, weight=200 pounds}

⌨️ 快捷键说明

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