Files
Java/com/study/demo3/StudentManager.java
2025-11-14 15:36:43 +08:00

29 lines
864 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);
}
}