Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Java
»
Beginning Java
using superclass constructor
nirjari patel
,
Ranch Hand
Mar 11, 2011 16:29:04
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
public class GraphicalDice extends PairOfDice { public GraphicalDice() { super(){} // This super class constructor gets called automatically, if nothing is specified in first line super(3,4); // Call the constructor from the // PairOfDice class, with parameters 3, 4. initializeGraphics(); // Do some initialization specific // to the GraphicalDice class. } super(7, 8); //can I make call like this ? . . // More constructors, methods, variables... . }
My question is, if I want to call super constructor outside of GraphicalDice constructor, can I do that ?
Thanks
Tom Reilly
,
Rancher
Mar 11, 2011 16:48:35
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
A constructor can only be called from another constructor. And a further restriction is a constructor can only be called from the first line of another constructor.
Wouter Oet
,
Bartender
staff
Mar 13, 2011 05:00:08
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
Why would you like to invoke the super constructor from another location?
Post by:
autobot
What are your superhero powers? Go ahead and try them on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
This thread has been viewed 1033 times.
Similar Threads
Must subclass call constructor of super class
Question regarding Inheritance
SCJP certification
super().this()!
this() and super()
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 05:13:30
.