File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Calling constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calling constructor" Watch "Calling constructor" New topic

Calling constructor

Supri dharshni

Joined: Jul 14, 2009
Posts: 25

Is there a way to call a constructor in a java class other than new,super keywords? I am asking for calling the constructor which is present in the same class.

Anbarasu Aladiyan
Ranch Hand

Joined: Jun 02, 2009
Posts: 182

using this keyword

Paul Beckett
Ranch Hand

Joined: Jun 14, 2008
Posts: 96
use "this":

Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
Within the same class, the only way to call another constructor is from another constructor to hand over or augment to the initialization process.

JDBCSupport - An easy to use, light-weight JDBC framework -
Supri dharshni

Joined: Jul 14, 2009
Posts: 25

Sorry i forgot to mention that i have call the constructor of a class without using new,this,super keywords.For example,

public class A{

public A(){

System.out.println("Hello Constructor");

public static void main(String args[]){


Now i have to print "Hello Constructor" without using new,this,super keywords.Is it possible?
Sean Clark

Joined: Jul 15, 2009
Posts: 377


I still question why you would want to do this, but this will work for classes that have default constructors:


I love this place!
Christian Dillinger
Ranch Hand

Joined: Jul 20, 2009
Posts: 189
Reflection would be another way but that's no topic for beginners.
I agree. Here's the link:
subject: Calling constructor