mirror of
https://github.com/Dichgrem/Java.git
synced 2025-12-16 20:42:00 -05:00
update:demo3
This commit is contained in:
28
com/study/demo3/StudentManager.java
Normal file
28
com/study/demo3/StudentManager.java
Normal file
@@ -0,0 +1,28 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user