Need of default constructor

A

arvind

hi,
i am new to java beans.
why is it necessary to use the default counstructor for a bean which
contains no parameters?
 
B

bharat

Becoz bean uses interospection to deside members of the class so it
need no argument constructor.
 
T

Thomas Hawtin

arvind said:
i am new to java beans.
why is it necessary to use the default counstructor for a bean which
contains no parameters?

The no-args constructor allows tools or libraries to construct a bean of
a given class. There's not much point fiddling with the properties and
events of a bean if you can't construct it in the first place.

(Point of pedantry: "Default constructor" with this meaning is a C++
term. In Java a default constructor is just the synthetic constructor
provided by the compiler if no others are present.)

Tom Hawtin
 
A

arvind

Thanks for the reply Thomas.

Thomas said:
The no-args constructor allows tools or libraries to construct a bean of
a given class. There's not much point fiddling with the properties and
events of a bean if you can't construct it in the first place.

(Point of pedantry: "Default constructor" with this meaning is a C++
term. In Java a default constructor is just the synthetic constructor
provided by the compiler if no others are present.)

Tom Hawtin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,075
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top