zoukankan      html  css  js  c++  java
  • Map里面的方法

    package test;
    
    
    import java.util.*;
    import java.util.Map.Entry;
    
    import javax.imageio.event.IIOReadWarningListener;
    import javax.security.auth.kerberos.KerberosKey;
    import javax.security.auth.x500.X500Principal;
    
    import privateclass.*;
    
    import java.io.*;
    import java.math.BigInteger;
    
    
    class lop
    {
    	public void te()
    	{
    		System.out.println("yey");
    	}
    }
     
    class Animal extends lop
    {
    	int num = 4;
    	public void eat()
    	{
    		
    	}
    }
    
    class Dog extends Animal
    {
    	
    	int num = 5;
    }
    
    
    interface kk
    {
    	public void wo();
    }
    
    interface dd
    {
    	public void wo();
    }
    
    class poue implements kk,dd{
    
    	@Override
    	public void wo() {
    		// TODO Auto-generated method stub
    		
    	}
    	
    }
    public class Main {
    
    	private static final String space_operator = " ";
    	public static void main(String[] args) throws Exception {
    
    		Scanner scanner = new Scanner(new BufferedInputStream(System.in));
    		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    		
    		Map<Integer, String> mp = new HashMap<Integer, String>();
    		
    		mp.put(8,"zhangsan");
    		mp.put(9,"lisi");
    		mp.put(10,"wangwu");
    		mp.put(11,"maliu");
    		mp.remove(11);
    		
    		for(Entry<Integer, String> x : mp.entrySet())
    		{
    			System.out.println(x.getKey() + "   " + x.getValue());
    		}
    		
    		for(String x : mp.values())
    		{
    			System.out.println(x);
    		}
    		
    		List<String> list = new ArrayList<String>();
    		list.add("shang");
    		list.add("kaishi");
    		
    		for(String x : list)
    		{
    			System.out.println(x);
    		}
    		
    		Set<Integer> keySet = mp.keySet();
    		
    		Iterator<Integer> it = keySet.iterator();
    		while(it.hasNext())
    		{
    			System.out.println(mp.get(it.next()));
    		}
    		
    		Set<Map.Entry<Integer, String>> entry = mp.entrySet();
    		Iterator<Map.Entry<Integer, String>> it2 = entry.iterator();
    		
    		while(it2.hasNext())
    		{
    			Entry<Integer, String> mEntry = it2.next();
    			System.out.println(mEntry.getValue() + "   " + mEntry.getKey());
    		}
    	}
    }
    

      

  • 相关阅读:
    [置顶] 移动应用不得不看的三张图
    重新签名apk文件(手工用命令行)
    o(n)解决问题:调整数组顺序是奇数位于偶数的前面
    安装DBMS_SHARED_POOL包
    sql server 实现sleep延时
    【Unity 3D】使用 2DToolkit 插件 制作2D精灵动画
    消息对话框(MessageBox)用法介绍
    java监控之ManagementFactory分析
    Java内存模型深度解析:总结--转
    Java内存模型深度解析:final--转
  • 原文地址:https://www.cnblogs.com/WINDZLY/p/11788665.html
Copyright © 2011-2022 走看看