Does Java bean's setter permit return this?

后端 未结 10 555
一向
一向 2020-12-06 10:02

can I define setter method to return this rather than void?

Like:

ClassA setItem1() {
      return this;
}

ClassA setItem2() {
      return this;
}
         


        
10条回答
  •  北海茫月
    2020-12-06 11:02

    Just to add that for people using Spring 3.1+ this is not an issue anymore

    see http://static.springsource.org/spring/docs/3.1.0.M2/spring-framework-reference/html/new-in-3.1.html

提交回复
热议问题