如何通过HashMap集合存储学生信息及其对应的描述字符串?
- 内容介绍
- 文章标签
- 相关推荐
本文共计177个文字,预计阅读时间需要1分钟。
javapackage day18;import day18.Student;import java.util.HashMap;
/** * 描述: * HashMap集合的键是Student,值是String的示例 * @author 71948 * @create 2017-10-06 22:19 */public class Demo5_JHashMap { public static void main(String[] args) { HashMap map=new HashMap(); // 假设有一个学生对象和一个与之对应的字符串 Student student1=new Student(张三, 20); String info=学生信息;
// 将学生对象和字符串添加到HashMap中 map.put(student1, info);
// 输出HashMap中的内容 System.out.println(map); }}
package day18.HashMap;
import day18.Student;
import java.util.HashMap;
/**
* 描述:
* HashMap集合键是Student值是String的案例
*
* @outhor 71948
* @create 2017-10-06 22:19
*/
public class Demo5_JHashMap {
public static void main(String[] args) {
HashMap
本文共计177个文字,预计阅读时间需要1分钟。
javapackage day18;import day18.Student;import java.util.HashMap;
/** * 描述: * HashMap集合的键是Student,值是String的示例 * @author 71948 * @create 2017-10-06 22:19 */public class Demo5_JHashMap { public static void main(String[] args) { HashMap map=new HashMap(); // 假设有一个学生对象和一个与之对应的字符串 Student student1=new Student(张三, 20); String info=学生信息;
// 将学生对象和字符串添加到HashMap中 map.put(student1, info);
// 输出HashMap中的内容 System.out.println(map); }}
package day18.HashMap;
import day18.Student;
import java.util.HashMap;
/**
* 描述:
* HashMap集合键是Student值是String的案例
*
* @outhor 71948
* @create 2017-10-06 22:19
*/
public class Demo5_JHashMap {
public static void main(String[] args) {
HashMap

