Null pointer exception with flag.equals ("true") in the hidden danger notation

Source: Internet
Author: User
Category:2008-06-04 12:47 467 people read reviews (0) Collection report Linuxjava test Yesterday, When a colleague A is testing a program written by colleague B, an error occurs, looking at the console information and discovering that a null pointer exception was thrown.

The survey results show that when flag does not have a corresponding attribute entry in the configuration file, this vulnerability flag.equals ("true") throws a null pointer error.

Workaround: Use the notation "true" for the specification. Equals (flag), so that if flag is empty, there will be no null pointer exception.




By the way, Equalsignorecase (String str):

public boolean equalsignorecase (String str)
To determine whether the current string is the same as the contents of STR, this method does not distinguish between uppercase and lowercase letters, which are not sensitive to case.

The case is sensitive in Java, and the Linux environment is insensitive to capitalization.

Null pointer exception with flag.equals ("true") in the hidden danger notation

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.