aspose file tools*
The moose likes Beginning Java and the fly likes Multiple Constructors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Multiple Constructors" Watch "Multiple Constructors" New topic
Author

Multiple Constructors

Joel Cochran
Ranch Hand

Joined: Mar 23, 2001
Posts: 301
Can I have a constructor that calls another constructor...
Program 1:
User currentUser = new User();
Program 2 (User):

------------------
I'm a soldier in the NetScape Wars...
Joel
[This message has been edited by Joel Cochran (edited December 05, 2001).]


Wait a minute, I'm trying to think of something clever to say...<p>Joel
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Absolutely, however there is one rule. The call must be made on the first line of the constructor. No where else. Also the syntax is a bit different than you used.

Of course if you call another constructor on the first line that prevents you from calling a specific super() constructor on that line - so make your design carefully.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Mathew Kuruvilla
Ranch Hand

Joined: Nov 27, 2001
Posts: 135
How come the code comes out differently in IE and Netscape. The first posting's code comes out too small in IE. The second comes posting's code comes out bigger in IE, but the same size as the first posting for IE. :-)
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
The first post was using the [ code][ /code] (without the spaces) tags and picks up the default font size.
The second post was using:
[ CODE]< font size=2.5>
< /font>[ /code]
(without the spaces)
and forces a font size.
You can also use< font size=+1>
etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple Constructors