Java——学生Map

本文介绍了如何使用Java中的Map数据结构来实现一个简单的学生信息管理。通过示例输入和输出,展示了如何存储和检索学生数据,为理解Java Map的应用提供了实例。
摘要由CSDN通过智能技术生成

Description

修改《学生列表》题目,使用学生Map来存放学生的集合,其中key为学号,value为学生对象
输出时按照学生的学号顺序输出

Input

学生个数
学生对象数据
操作数
操作内容

Output

按照学号顺序输出集合中的学生

Sample Input

4
1 wong 90
2 liu 80
3 chen 70
4 fang 60
3
add 5 duan 80
delete 3
set 4 70

Sample Output

no:1 name:wong score:90
no:2 name:liu score:80
no:4 name:fang score:70
no:5 name:duan score:80
import java.util.*;

class Student{

    private int no;

    private String name;

    private int score;

    

    public Student(int no, String name,int score) {

        this.no = no;

        this.name = name;

        this.score = score;

    }

    public String toString()

    {

        return "no:" + this.no + " name:" + this.name + " score:" + this.score;

  
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值