mirror of
https://github.com/Dichgrem/Java.git
synced 2025-12-16 20:42:00 -05:00
30 lines
795 B
Java
30 lines
795 B
Java
package com.study.demo3;
|
|
|
|
import java.util.*;
|
|
|
|
public class StudentManager {
|
|
public static void main(String[] args) {
|
|
List<String> studentNames = new ArrayList<>();
|
|
Map<String, Integer> studentScores = new HashMap<>();
|
|
|
|
studentNames.add("张三");
|
|
studentNames.add("李四");
|
|
studentNames.add("王五");
|
|
|
|
studentScores.put("张三", 85);
|
|
studentScores.put("李四", 77);
|
|
studentScores.put("王五", 99);
|
|
|
|
System.out.println("--- 所有学生姓名 ---");
|
|
for (String name : studentNames) {
|
|
System.out.println(name);
|
|
}
|
|
|
|
studentScores.put("张三", 70);
|
|
|
|
Integer zhangsanScore = studentScores.get("张三");
|
|
System.out.println("\n--- 修改后张三的成绩 ---");
|
|
System.out.println("张三的成绩: " + zhangsanScore);
|
|
}
|
|
}
|