20170217问题解析请点击今日问题下方的“【Java每日一题】20170220”查看(问题解析在公众号首发,公众号ID:weknow619)
package Feb2017; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class Ques0220 { public static void main(String[] args) { List<Student> list = new ArrayList<Student>(); list.add(new Student("001")); Map<Student, Object> map = new HashMap<Student, Object>(); map.put(new Student("001"), new Object()); System.out.println("list是否包含001:"+list.contains(new Student("001"))); System.out.println("map是否包含001:"+map.containsKey(new Student("001"))); } } class Student{ private String stuId; public Student(String stuId) { super(); this.stuId = stuId; } public String getStuId() { return stuId; } public void setStuId(String stuId) { this.stuId = stuId; } @Override public boolean equals(Object obj) { if(obj instanceof Student){ Student stu = (Student) obj; if(stu.getStuId() == null || stuId == null){ return false; }else{ return stuId.equalsIgnoreCase(stu.getStuId()); } } return false; } }
今日问题:
请问主程序输出结果是什么?(点击以下“【Java每日一题】20170220”查看20170217问题解析)
题目原发布于公众号、简书:【Java每日一题】20170220,【Java每日一题】20170220 (也可以扫描头像二维码查看)