须要继承Map的equals函数和hashCode函数

package com.category;

import java.util.HashMap;

public class GenCategoryLevelData {

	private static HashMap<Category, Integer> categoryLevel = new HashMap<Category, Integer>();
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub } /**
* 分类
* @author ouyangyewei
*
*/
public static class Category {
public long categoryId;
public String categoryName; @Override
public boolean equals(Object obj) {
Category category = (Category)obj;
return (this.categoryId==category.categoryId
&& this.categoryName.equals(category.categoryName));
}
@Override
public final int hashCode() {
int hashCode = 17;
hashCode = hashCode * 31 + 1;
hashCode = hashCode * 31 + 1;
return hashCode;
} public Category() {
// empty
}
public Category(long categoryId, String categoryName) {
this.categoryId = categoryId;
this.categoryName = categoryName;
}
public long getCategoryId() {
return categoryId;
}
public void setCategoryId(long categoryId) {
this.categoryId = categoryId;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
}
}

最新文章

  1. 集群节点间网络通信TIPC
  2. windows下如何安装和启动MySQL
  3. tiny4412学习一:编译uboot,体验裸机
  4. 【Spring开发】—— Spring Core
  5. 禁止Android的StatusBar下拉
  6. word 中Sentences、Paragraph等含义和用法
  7. 配置php中的Oracle扩展
  8. 自己实现的一个简单的EF框架(反射实现)
  9. 深入理解计算机系统_3e 第三章家庭作业 CS:APP3e chapter 3 homework
  10. new words
  11. VS快捷键失效问题
  12. 【CF1154】题解
  13. python bytes类型去除尾部字节
  14. 用casperjs模拟登录,支持多个账户登录
  15. openx _金额
  16. 电商商品规则属性sku 工具类
  17. 线程不安全的类不要轻易做为static变量使用,及如何使用ThreadLocal将共享变量变为独享变量
  18. vue2.0非父子间进行通讯
  19. Ubuntu下改变文件权限
  20. Why Isn&#39;t curr_items Decreasing When Items Expire?

热门文章

  1. nyoj 37
  2. MVC验证码的编写
  3. OUTPUT新增记录入库示例C#+存储过程
  4. 运维监控利器smokeping 500报错处理
  5. 拿起cl.exe,放下IDE
  6. asp.net能不托管吗?
  7. SQL复制表结构和数据
  8. sublime 使用快捷记录
  9. 转:exit()与_exit()的区别
  10. Altium Designer 6 快速进行差分对走线