package list1;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Scanner;public class List3 { private static final List<Map<String,Object>> list = new ArrayList<Map<String,Object>>(); public static void main(String[] args) { // TODO Auto-generated method stub Map<String,Object> map = new HashMap<String, Object>(); do { System.out.println("**************请输入如下选项****************"); System.out.println("\t\t1、信息录入"); System.out.println("\t\t2、信息查询"); System.out.println("\t\t3、退出"); @SuppressWarnings("resource") Scanner input = new Scanner(System.in); int flat = input.nextInt(); switch (flat) { case 1: System.out.println("请输入ID:"); String name = input.next(); System.out.println("请输入书名"); String id = input.next(); System.out.println("请输入描述:"); String book = input.next(); map.put("name", name); map.put("id",id); map.put("book",book); list.add(map); break; case 2: // System.out.println("请输入查询的ID:");// // do {// String id11 = input.next();// @SuppressWarnings("unchecked")// List<Map<String,Object>> id1= (List<Map<String, Object>>) map.get(id11);// if(id1!=null) {// System.out.println("对不起请从新输入:");// continue;// }// for(Map<String,Object> aa:list) { System.out.println("姓名:"+aa.get("name")+" id:"+aa.get("id")+" 书名:"+aa.get("book")); } break; //}while(true); case 3: System.exit(0); System.out.println("退出!"); break; } }while(true); }}
添加回答
举报
0/150
提交
取消