Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Constructors

 
Joel Cochran
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mathew Kuruvilla
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic