java.util.HashMap.remove()方法实例
来源:互联网 发布:听歌不要钱的软件 编辑:程序博客网 时间:2024/05/18 22:40
java.util.HashMap.remove()方法实例
评论 编辑<iframe id="iframeu1064372_0" src="http://pos.baidu.com/ncpm?rdid=1064372&dc=2&di=u1064372&dri=0&dis=0&dai=1&ps=323x335&dcb=BAIDU_SSP_define&dtm=BAIDU_DUP_SETJSONADSLOT&dvi=0.0&dci=-1&dpt=none&tsr=0&tpr=1459144932123&ti=java.util.HashMap.remove()%E6%96%B9%E6%B3%95%E5%AE%9E%E4%BE%8B&ari=1&dbv=2&drs=1&pcs=1156x572&pss=1156x1476&cfv=0&cpl=4&chi=1&cce=true&cec=UTF-8&tlm=1459144932&ltu=http%3A%2F%2Fwww.yiibai.com%2Fjava%2Futil%2Fashmap_remove.html&ltr=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3DVkT4Wu3jerwwEb_aVTyNxDl-nqpX4imXbibIKyRBSVo1lVaC4ooKlwSDMtzqaESxMxKRWWdZ-TDR7Tva4Eb2B_%26wd%3D%26eqid%3Df3f6d89b0001bfd40000000556f8c8a5&ecd=1&psr=1366x768&par=1366x728&pis=-1x-1&ccd=24&cja=false&cmi=6&col=zh-CN&cdo=-1&tcn=1459144932&qn=9a4841f476805c55&tt=1459144932000.126.312.314" width="728" height="90" align="center,center" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" allowtransparency="true" style="border-width: 0px; border-style: initial; vertical-align: bottom; margin: 0px;"></iframe>
描述
The remove() method is used to remove the mapping for the specified key from this map if present.
声明
Following is the declaration for java.util.HashMap.remove() method.
public V remove(Object key)
参数
key--This is the key whose mapping is to be removed from the map.
返回值
The method call returns the previous value associated with key, or null if there was no mapping for key.
异常
NA
实例一
编辑+分享实例以下例子将告诉你如何使用 java.util.HashMap.remove()
package yiibai.com;import java.util.*;public class HashMapDemo { public static void main(String args[]) { // create hash map HashMap newmap = new HashMap(); // populate hash map newmap.put(1, "tutorials"); newmap.put(2, "point"); newmap.put(3, "is best"); System.out.println("Values before remove: "+ newmap); // remove value for key 2 newmap.remove(2); System.out.println("Values after remove: "+ newmap); } }
Let us compile and run the above program, this will produce the following result.
Values before remove: {1=tutorials, 2=point, 3=is best}Values after remove: {1=tutorials, 3=is best}
0 0
- java.util.HashMap.remove()方法实例
- java.util.HashMap.remove()方法的使用
- [Java] java.util.HashMap
- java.util.HashMap
- HashMap java.util.ConcurrentModificationException
- HashMap java.util.ConcurrentModificationException
- 细说java.util.HashMap
- HashMap java.util.ConcurrentModificationException
- 13 java.util.HashMap
- java.util包---HashMap
- java.util.HashMap
- java.util.HashMap
- java.util.List的remove()方法使用技巧
- 关于 list.remove(obj);方法在迭代器中报java.util.ConcurrentModificationException
- java.util.List的remove()方法使用技巧(转)
- java.util.Collections.swap()方法实例
- java.util.Date.getTime()方法实例
- java.util.Properties.getProperty()方法实例
- 用户登陆的退出
- 大数据的误区
- OpenJsCad - 在线3D图像浏览与编辑
- delphi中Application.MessageBox函数用法详解
- 一致性Hash
- java.util.HashMap.remove()方法实例
- 关于HTTP协议中的KeepAlive属性
- 测试222
- cocos2dx3.3 CCNotificationCenter观察者模式
- jQuery源码剖析(一)——概览&工具方法
- CentOS发送邮件(sendmail)
- DI IOC区别
- Android侧滑结束当前页
- 【记录】Apache POI - the Java API for Microsoft Documents - 15秒快速入门