8 Replies Latest reply: Mar 23, 2009 1:13 AM by 843807 RSS

    get and set

    843807
      Hi all,

      I have a doubt with get and set methods in bean class..

      Out method name of the getter and setter method name should start with get and set, why is it so?
      Where they mentioned it in the Java API?
        • 1. Re: get and set
          800305
          Maybe this is a name convention ?
          • 2. Re: get and set
            843807
            Skowroniasty wrote:
            Maybe this is a name convention ?
            No, it is not.
            If your method names does not start with get and set then it wont work.
            • 3. Re: get and set
              800305
              Yes, I know IT,
              but maybe this is only one sense? This convention facilitate reads code from other developers.
              Hmm... write mail to this guy and paste his answer: http://www.horstmann.com/corejava.html (it is not spam)

              Edited by: Skowroniasty on Mar 19, 2009 3:22 PM
              • 4. Re: get and set
                843807
                itzraghavan wrote:
                Skowroniasty wrote:
                Maybe this is a name convention ?
                No, it is not.
                Yes it is.

                It is the JavaBeans naming convention. Please be less rude and trollish.
                • 5. Re: get and set
                  843807
                  cotton.m wrote:
                  itzraghavan wrote:
                  Skowroniasty wrote:
                  Please be less rude and trollish.
                  Sure man I will.

                  I am using Struts 1 framework in my project and I have tested it over there.
                  In Struts we call the ActionForm class as bean class, which will have getters and setters for the properties that we use in our jsp file.
                  I tried to open the jsp page after changing the method names (like it wont start with get and set), but I am getting error.

                  Please explain..
                  • 6. Re: get and set
                    800305
                    Please be less rude and trollish.
                    my is not r & t.

                    I wrote, what I think.serious
                    • 7. Re: get and set
                      843807
                      It is not the issue man.....
                      Answer my doubt.
                      • 8. Re: get and set
                        843807
                        With regard to the reply above..

                        I am using Struts 1 framework in my project and I have tested it over there.
                        In Struts we call the ActionForm class as bean class, which will have getters and setters for the properties that we use in our jsp file.
                        I tried to open the jsp page after changing the method names (like it wont start with get and set), but I am getting error.

                        Please explain..