Quantcast
Channel: Code inside the constructor - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by Not a bug for Code inside the constructor

There are two alternative to using a constructor to initialize instance members...First one is Instance initialization block, { // whatever code is needed for initialization goes here...

View Article



Answer by Braj for Code inside the constructor

Use Initialization block if you have overloaded constructor to avoid repetition of code.public class MyClass{ private List<MyObject> lst; //Initialization block { //----Starting initial code-----...

View Article

Code inside the constructor

I have the following Java class:public class MyClass{ private List<MyObject> lst; public MyClass(){ //----Starting initial code----- MyAdditionalObject obj=new MyAdditionalObject(); Event e= new...

View Article
Browsing latest articles
Browse All 3 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>