Can a JavaBean use methods other than getters and setters?

According to the definitions I found on the Internet, a JavaBean is a Java class that satisfies the following conditions:

  • All instance attributes are private.
  • All instance attributes have public receivers and setters
  • The class has a constructor without parameters
  • The class implements the Serializable interface.

What I would like to know is that if I add a method to Javabean, can we call it javabean?

As an example, you can say that the next class is a JavaBean?

public class Person implements Serializable {
    private String name;
    public Person(){}
    public String getName(){...}
    public void setName(String name){...}
    public void sayHello(){}
}
+4
source share
2 answers

, Java Beans . Java Bean , , .

Oracle Java Beans:

A Bean - , . , , - Bean. Bean , NetBeans, Bean . , , Bean.

+7

, java beans . , . , , GUI swing, bean GUI. GUI . , , . , , DTO ( ), , .

+2

Source: https://habr.com/ru/post/1534867/


All Articles