标签:unix void ring for java keyset logs code tom
import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Scanner; import java.util.Map.Entry; import java.util.Set; public class TeachClass { public static void main(String[] args) { String[]pro={"tom,corejava","john,oracle","susan,oracle","jerry,jdbc","jim,unix","kevin,jsp","lucy,jsp"}; Map<String,String>map=new HashMap<String,String>(); for(String s:pro){ String[]v=s.split(","); map.put(v[0],v[1]); } map.put("allen", "jdbc"); map.put("lucy", "corejava"); Set<Map.Entry<String, String>>set=map.entrySet(); for(Entry<String, String> i:set){ System.out.println(i); } Scanner s=new Scanner(System.in); System.out.println("请输入课程"); String c=s.next(); Set<String>sset=map.keySet(); for(String i:sset){ if(map.containsValue(c)){ if(map.get(i).equals(c)){ System.out.println(i); } }else{ System.out.println("没有这门课"); } } } }
标签:unix void ring for java keyset logs code tom
原文地址:http://www.cnblogs.com/zyy1130/p/6830381.html