What's the point of beans?

后端 未结 6 1723
故里飘歌
故里飘歌 2020-12-20 11:36

I\'ve bean doing some JSP tutorials and I don\'t understand what the point of a bean class is. All it is, is get and set methods. why do we use them?

public          


        
6条回答
  •  爱一瞬间的悲伤
    2020-12-20 12:14

    The accessor(getter) and mutator(setter) methods are generally used to provide encapsulation. As the instance variables are private they can only be accessed outside the class through these methods.

    So In layman : the ability to make change in your implementation code without breaking the code of others who use your code is key benefit of encapsulation.

提交回复
热议问题