J
Justin Kaeser
Hello helpful folks,
Is there a way to call a classes default constructor from another
constructor *after* calling it's superconstructor? The scenario is
somewhat like this:
class Foo
{
Bdauh augh;
String name;
Foo()
{ name = "Mr. Foo" }
Foo(Bdauh a)
{ augh = a }
{
class Bar extends Foo
{
Bar()
{ name = "Mr. Bar" }
Bar(Bdauh a)
{
super(a);
// after this I want to call Bar()
}
}
Now I want to create a Bar object with a Bdauh as parameter.
If I call this() from Foo, the name of the constructed object will be
"Mr. Foo".
Calling this() from Bar(Bdauh a) on the other hand won't work at all
after calling super(a). So how can I call the default constructor?
Or do I have to work around it using an init() method which is called
from the Foo constructor?
Is there a way to call a classes default constructor from another
constructor *after* calling it's superconstructor? The scenario is
somewhat like this:
class Foo
{
Bdauh augh;
String name;
Foo()
{ name = "Mr. Foo" }
Foo(Bdauh a)
{ augh = a }
{
class Bar extends Foo
{
Bar()
{ name = "Mr. Bar" }
Bar(Bdauh a)
{
super(a);
// after this I want to call Bar()
}
}
Now I want to create a Bar object with a Bdauh as parameter.
If I call this() from Foo, the name of the constructed object will be
"Mr. Foo".
Calling this() from Bar(Bdauh a) on the other hand won't work at all
after calling super(a). So how can I call the default constructor?
Or do I have to work around it using an init() method which is called
from the Foo constructor?