【Java每日一題】20170220。本站提示廣大學習愛好者:(【Java每日一題】20170220)文章只能為提供參考,不一定能成為您想要的結果。以下是【Java每日一題】20170220正文
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 (也可以掃描頭像二維碼查看)
weknow團隊已開通認證了分答,有問題也可以來咨詢,點擊分答就可以找到我了!!