Key Java Technologies (12) The JavaBean of introspection

Source: Internet
Author: User

1.1.Java Bean

A Java Bean is a class that conforms to a particular rule. At least the following rules are met:

(1) class itself is Public modified.

(2) class has Public no parameter constructor.

(3) class through some kind of normalized GetXXX () and the setxxx () method to expose its properties XXX .

Main rules:

(a) properties are generally Private , while Get and the Set method is Public .

   (b) 1 get set is the property's get set method name. Property xxx corresponding method is getxxx () Setxxx () xyz corresponding method is getxyz () SETXYZ ()

(c) Property Type is Boolean when you use the isxxx () Replace GetXXX () .

here is a rule-compliant Java Bean.

/*** @Title: samplebean.java* @Package com.test.javatechnology.introspection* @Description:*@author http://www.cnblogs.com/coe2coe/* @date March 25, 2017 PM 4:51:30*@versionV1.0*/ Packagecom.test.javatechnology.introspection;/*** @ClassName: samplebean* @Description:*@author http://www.cnblogs.com/coe2coe/* @date March 25, 2017 PM 4:51:30**/ Public classSamplebean {/*** No parameter constructor*/ PublicSamplebean () {}/*** Get Age *@return */ Public intGetage () {returnAge ;}/*** Set Age *@param Age*/ Public voidSetage (intAge ) { This. Age =Age ;}/*** Get name *@return */ PublicString GetName () {returnname;}/*** Set name *@paramname*/ Public voidsetName (String name) { This. Name =name;} /*** Get Turn *@return */ Public BooleanIsturn () {returnturn;}/*** Set Turn *@paramTurn*/ Public voidSetturn (Booleanturn) { This. turn =turn;} Private intAge ;PrivateString name;Private Booleanturn;}

Key Java Technologies (12) The JavaBean of introspection

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.