About Java attribute field naming

Source: Internet
Author: User

When a recent project defines VO, the boolean data is defined as Isproperty type, resulting in an error during data interaction between systems.

The internet has been crawling for a long while:

The JavaBean naming convention specifies that for primitive and custom class type property (lowercase), getter and setter methods are GetProperty and SetProperty (the first letter becomes uppercase, Before adding a get or set). For properties of type Boolean, the Getter method can also be written as Isproperty (GetProperty is still available), and, if the first two letters of the property are is (two lowercase), The getter is exactly the same as the property (for example, the getter of the above attribute IsActive is IsActive ()).

If there is a Boolean property called Isisactive, what about its getter? The answer is still isisactive ()

So, whether the property name is IsActive or active,getter can only be isactive () or getactive (), JSP can only be accessed with ${user.active} (note case).

The best thing to do is not to use "is" as the beginning to name a Boolean-type property to avoid confusion.

About Java attribute field naming

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.