开发者

Is this class a POJO

I have a doubt regarding POJO.

Take below开发者_开发技巧 example

public class User
{
     String user="";
     String password="";
     String firstName="";
     String lastName="";
     ChallengeQuestions challengeQuestions;

     //getter and setters for these prooperties
}

public class ChallengeQuestions
{
    String question="";
    String answer="";

    //getter and setters for these properties
}

Here is my question, whether User class is a POJO or not.

Thanks,

Narendra


POJO i.e. Plain Old Java Object refers to all user defined types that do not have to extend a specific/special prespecified class or specialized prespecified interface.
Your class fits in this category so it is a POJO.


Yes, it is. See 'Plain Old Java Object' (Wikipedia).

The term "POJO" is mainly used to denote a Java object which does not follow any of the major Java object models, conventions, or frameworks.


I would have said that a POJO is distinct from a JavaBean. A POJO does not need to have setters or getters and it would more clearly be a POJO without them.

Your comments suggests you intended to add getters and setters to follow the JavaBean standard and as such this is not a POJO as it is intended to comply with the JavaBean convention.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜