[Java daily question] 20170208, java20170208

Source: Internet
Author: User

[Java daily question] 20170208, java20170208

20170207 for problem resolution, click "Java daily question" 20170208 "below today's question to view the problem (The problem is resolved at the beginning of the public account, public ID: weknow619)

package Feb2017;    public class Ques0208 {    }    class Person{          private String id;          private String name;            public Person(String id, String name) {                  super();                  this.id = id;                  this.name = name;      }            @Override      public boolean equals(Object o) {          if (o != null && o instanceof Person) {              Person person = (Person)o;              return (id.equals(person.id) && name.equals(person.name));          }          return false;      }  }  

Today's question:
In the if condition judgment of the equals method in the Person class, if the object is not checked for being null (remove o! = Null, write only o instanceof Person). If the input object is null, will a null pointer exception be reported? (Click "[Java daily question] 20170208" below to view issue resolution 20170207)

Questions originally published on the public account and short book: [Java daily question] 20170208, [Java daily question] 20170208 (you can also scan the Avatar QR code to view)

The weknow team has activated the authentication and has answered questions. If you have any questions, you can also consult. Click the answer to find me!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.