我正在使用 Maps 集合创建学生管理简单的 java 项目,其中 id 是我的密钥,名称、标记和手机号码。是地图的值。那么如何以结构化的方式打印它。
HashMap<Integer, LinkedHashSet<StudentCinstructor>> st = new HashMap<>();
LinkedHashSet<StudentCinstructor> st2 = new LinkedHashSet<>();
Scanner sc = new Scanner(System.in);
public void add() {
System.out.println("enter the name of the student");
String name = sc.nextLine();
System.out.println("enter the marks of the student");
double marks = sc.nextDouble();
System.out.println("enter the mobile number of the student");
long mobile_no = sc.nextLong();
st2.add(new StudentCinstructor(name, marks, mobile_no));
System.out.println("enter the unique id of the student");
int id = sc.nextInt();
st.put(id, st2);
当我尝试在主方法中打印自定义类时,它给了我一个带有哈希码的地址。“HashmapDemo.MethodsForManagement@3d4eac69”
慕森王
蓝山帝景
猛跑小猪
随时随地看视频慕课网APP
相关分类