i am new in java can any one please tell me the main use of constructor
if we can use method
in what cases its necessary to use constuctor

Study the information found in the "Read Me: Starting Java" thread that is stickied at the top of this forum.

i am new in java can any one please tell me the main use of constructor
if we can use method
in what cases its necessary to use constuctor

just give it a simple though, there is Object in Java, and the Object has Method which is its accessor. SO you cannot access the Object accessor before the Object itself is created (initialized) isn't it, except the method is static (which don't necessarily the Object to be instantiated), and one way to create/instantiate an Object is to call it constructor, jvm will give empty constructor for your classess even if you don't provide one.

hope it will give you some light.

regards,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.