| clear() | 从 Map 中删除所有映射 |
| remove(Object key) | 从 Map 中删除键和关联的值 |
| put(Object key, Object value) | 将指定值与指定键相关联 |
| putAll(Map t) | 将指定 Map 中的所有映射复制到此 map |
| entrySet() | 返回 Map 中所包含映射的 Set 视图。Set 中的每个元素都是一个 Map.Entry 对象,可以使用 getKey() 和 getValue() 方法(还有一个 setValue() 方法)访问后者的键元素和值元素 |
| keySet() | 返回 Map 中所包含键的 Set 视图。如果要删除 Set 中的元素还将会删除 Map 中相应的映射(键和值) |
| values() | 返回 map 中所包含值的 Collection 视图。如果要删除 Collection 中的元素还将会删除 Map 中相应的映射(键和值) |
| get(Object key) | 返回与指定键关联的值 |
| containsKey(Object key) | 如果 Map 包含指定键的映射,则返回 true |
| containsValue(Object value) | 如果此 Map 将一个或多个键映射到指定值,则返回 true |
| isEmpty() | 如果 Map 不包含键-值映射,则返回 true |
| size() | 返回 Map 中的键-值映射的数目 |
public static void main(String[] args) {
Map< Serializable, Serializable > map = new HashMap< Serializable, Serializable >();
map.put(null,null);
map.put("a", "1");
map.put("b", "2");
map.put("c", "3");
if (map.containsKey("a")) {
System.out.println("Key=Ture");
if (map.containsValue("1")) {
System.out.println("value=Ture");
}
}
}
public static void main(String[] args) {
Map< Serializable, Serializable > map = new HashMap< Serializable, Serializable >();
map.put(null,null);
map.put("a", "1");
map.put("b", "2");
map.put("c", "3");
Set<Entry<Serializable, Serializable>> entrySet= map.entrySet();
System.out.println("entrySet="+entrySet);
for (Entry key : entrySet) {
System.out.println("key.getKey="+key.getKey()+" key.getValue()="+ key.getValue());
}
}
public static void main(String[] args) {
Map< Serializable, Serializable > map = new HashMap< Serializable, Serializable >();
map.put(null,null);
map.put("a", "1");
map.put("b", "2");
map.put("c", "3");
Set keySet= map.keySet();
System.out.println("keySet="+keySet);
for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
Object key = (Object) iterator.next();
Object value = map.get(key);
System.out.println("key = "+key+ " value="+value);
}
}
public static void main(String[] args) {
Map<Serializable, Serializable> map = new HashMap<Serializable, Serializable>();
map.put(null, null);
map.put("a", "1");
map.put("b", "2");
map.put("c", "3");
Collection c = map.values();
System.out.println("map.values()=" + map.values());
for (Iterator iterator = c.iterator(); iterator.hasNext();) {
Object value = (Object) iterator.next();
System.out.println("value="+value);
}
}
public class HqlMap {
public static void main(String[] args) {
Map<Serializable, Serializable> map = new HashMap<Serializable, Serializable>();
map.put("isDelete", 0);
map.put("roomTypeName", "test");
Map<Serializable, Serializable> map1 = new HashMap<Serializable, Serializable>();
StringBuilder hqlBuilder = new StringBuilder();
hqlBuilder.append(" from Build ");
String hql = "" ;
if (map.isEmpty()) {
hql=hqlBuilder.toString();
} else {
hqlBuilder.append(" where ");
Set keySet = map.keySet();
for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
Object key = (Object) iterator.next();
hqlBuilder.append(key + "=:" + key + " and ");
}
//去掉最后的一个and
int lastIndex = hqlBuilder.lastIndexOf("and");
if (lastIndex > -1) {
hql = hqlBuilder.substring(0, lastIndex)
+ hqlBuilder.substring(lastIndex + 3,
hqlBuilder.length());
}
}
System.out.println(hql);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有