Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a "Java Bean"? [duplicate]

The name really throws me off. I'm hoping someone can explain it in a way I won't forget :)

like image 850
mrblah Avatar asked Dec 29 '09 05:12

mrblah


People also ask

What does @bean means in Java?

JavaBeans are classes that encapsulate many objects into a single object (the bean). It is a java class that should follow following conventions: Must implement Serializable. It should have a public no-arg constructor. All properties in java bean must be private with public getters and setter methods.

Is JavaBean reusable?

yes java beans are piece of reusable codes,this means that you can reuse it any where.

What does clone () do in Java?

The class Object 's clone() method creates and returns a copy of the object, with the same class and with all the fields having the same values. However, Object. clone() throws a CloneNotSupportedException unless the object is an instance of a class that implements the marker interface Cloneable .

Is Java clone a deep copy?

clone() is indeed a shallow copy. However, it's designed to throw a CloneNotSupportedException unless your object implements Cloneable . And when you implement Cloneable , you should override clone() to make it do a deep copy, by calling clone() on all fields that are themselves cloneable.


2 Answers

Any serializable java class (implementing java.io.Serializable) that follows specific conventions: a no-argument constructor, and properties accessible via get/set/is accessors.

The idea is to make it predictable, so that properties etc can be discovered automatically through reflection - of great help in tool and framework development.

like image 134
Marc Paradise Avatar answered Oct 02 '22 19:10

Marc Paradise


http://en.wikipedia.org/wiki/JavaBean

JavaBeans are reusable software components for Java that can be manipulated visually in a builder tool. Practically, they are classes written in the Java programming language conforming to a particular convention. They are used to encapsulate many objects into a single object (the bean), so that they can be passed around as a single bean object instead of as multiple individual objects. A JavaBean is a Java Object that is serializable, has a nullary constructor, and allows access to properties using getter and setter methods.

continue reading »

alt text

like image 25
Sampson Avatar answered Oct 02 '22 19:10

Sampson