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

📄 hashtableenumeration.java~2~

📁 some example source of java,for beginner.inside there are a lot of sample examples
💻 JAVA~2~
字号:
package example5;

import java.util.*;

public class HashtableEnumeration {
  public static void main(String[] args) {
    HE he = new HE();
    he.init();
    he.print();
  }
}

class HE {
  public Hashtable rightList;
  public void init() {
    String[] accRoleList = {
        "admin", "satrap", "manager", "user", "guest"};
    String[] rightCodeList = {
        "10001", "10011", "10021", "20011", "24011"};
    for (int i = 0; i < accRoleList.length; i++) {
      rightList.put(accRoleList[i], rightCodeList[i]);
    }
  }

  public String getRight(String accRole) {
    if (rightList.containsKey(accRole)) {
      return (String) rightList.get(accRole);
    }
    else {
      return null;
    }
  }

  public void delete(String accRole) {
    if (rightList.containsKey(accRole)) {
      rightList.remove(accRole);
    }
  }

  public void print() {
    Enumeration RLKey = rightList.keys();
    while (RLKey.hasMoreElements()) {
      String accRole = RLKey.nextElement().toString();
      System.out.println(accRole + "=" + this.getRight(accRole));
    }
  }
}

⌨️ 快捷键说明

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