常用类与工具类

package javaprac;

import java.util.Map;
import java.util.Stack;
import java.util.HashMap;
/*
 * @Collection
 * Set(HashSet,SortedSet),Queue(PriorityQueue,Deque),List(ArrayList,Vector)
 * @Map
 * LinkedHashMap,HashMap,SortedMap等
 * 这里选择Stack和Map举例,其他的常用类及其方法可以查手册学习
 * */
public class commonStruDemo {
	public static void main(String[] args) {
		//Stack操作
		Stack<String> s = new Stack<String>();
		s.push("hello");
		s.push("world");
		s.push("java");
		System.out.println(s.pop());	//java
		System.out.println(s.pop());	//world
		System.out.println(s.pop());	//hello
		
		//HashMap
		Map<String,Integer> hm = new HashMap<String,Integer>();
		hm.put("1001",100);
		hm.put("1002",90);
		hm.put("1003",98);
		System.out.println(hm);			//{1003=98, 1002=90, 1001=100}
		System.out.println("key值为1002的value值是:"+hm.get("1002"));	//key值为1002的value值是:90	
	}
}
发布了61 篇原创文章 · 获赞 61 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_42475914/article/details/100755783