标签:3.2 oid stat i++ 数组 java main ack scanner
package Collection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class collection {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
Map <String,String> map=new HashMap <String,String>(); //以数组方式放入;<两个都是字符串型>
map.put("白羊座", "3.21-4.19");
map.put("金牛座", "4.20-5.20");
map.put("双子座", "5.21-6.21");
map.put("巨蟹座", "6.22-7.22");
map.put("狮子座", "7.23-8.22");
map.put("处女座", "8.23-9.22");
map.put("天秤座", "9.23-10.23");
map.put("天蝎座", "10.24-11.22");
map.put("射手座", "11.23-12.21");
map.put("摩羯座", "12.22-1.19");
map.put("水瓶座", "1.20-2.18");
map.put("双鱼座", "2.19-3.20");
String a=scanner.next();
String[] _a=a.split(",");
for(int i=0;i<_a.length;i++){
if(map.containsKey(_a[i])){
System.out.println(_a[i]+"的取值范围是:"+map.get(_a[i])); //map.get:表示取出这个key所对应的value值。
}
}
scanner.close();
}
标签:3.2 oid stat i++ 数组 java main ack scanner
原文地址:http://www.cnblogs.com/hljj/p/6903025.html