Java每日一题20161229

作者: weknow | 来源:发表于2016-12-29 08:42 被阅读42次

    20161228问题解析请点击今日问题下方的“【Java每日一题】20161229”查看(问题解析在公众号首发,公众号ID:weknow619)

    package Dec2016;
    
    import java.util.ArrayList;
    import java.util.List;
    
    public class Ques1229 {
    
        public static void main(String[] args) {
            
            Student stu01 = new Student("001");
            Student stu02 = new Student(null);
            
            List<Student> students = new ArrayList<Student>();
            students.add(stu01);
            students.add(stu02);
            System.out.println("students是否包含001学号:"+students.contains(stu01));
            System.out.println("students是否包含null:"+students.contains(stu02));
        }
    }
    
    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;
                return stuId.equalsIgnoreCase(stu.getStuId().trim());
            }
            return false;
        } 
    }
    

    今日问题:
    请问主程序输出结果是什么?(点击以下“【Java每日一题】20161229”查看20161228问题解析)

    weknow团队已开通认证了分答,有问题也可以来咨询,点击下面的扩展阅读就可以找到我了!!

    相关文章

      网友评论

        本文标题:Java每日一题20161229

        本文链接:https://www.haomeiwen.com/subject/tgoqvttx.html