how about "instance initializer block" ? #4579
Answered
by
huoyaoyuan
athinboy
asked this question in
Language Ideas
-
there is a feature "instance initializer block" in java: class Box{
public int level;
public int length;
public int width;
public int height;
public Box(int length,int width,int height){
this.length=length;
this.width=width;
this.height=height;
}
//-----some other contructors
//-------------------------------
}
class SmallBox:Box{
{
this.level=1;
}
}
class MiddleBox:Box{
{
this.level=1;
}
}
class BigBox:Box{
{
this.level=1;
}
}
|
Beta Was this translation helpful? Give feedback.
Answered by
huoyaoyuan
Mar 24, 2021
Replies: 1 comment
-
I believe most of the usage can be covered by member initializer. Other of them can be a private constructor called by others. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
athinboy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe most of the usage can be covered by member initializer. Other of them can be a private constructor called by others.