About 1,790,000 results
Open links in new tab
  1. Best way to handle multiple constructors in Java

    I've been wondering what the best (i.e. cleanest/safest/most efficient) way of handling multiple constructors in Java is? Especially when in one or more constructors not all fields are …

  2. Java Constructors - Stack Overflow

    Aug 21, 2016 · 3 I generally put my constructors up near the top of my file, after package, import, Javadoc, and static/instance variable declaration sections.

  3. java - Can an abstract class have a constructor? - Stack Overflow

    Nov 4, 2008 · 1 In order to achieve constructor chaining, the abstract class will have a constructor. The compiler keeps Super () statement inside the subclass constructor, which will call the …

  4. function - Purpose of a constructor in Java? - Stack Overflow

    Nov 13, 2013 · 51 Constructors are used to initialize the instances of your classes. You use a constructor to create new objects often with parameters specifying the initial state or other …

  5. How to best explain and use empty Constructors in Java?

    Sep 25, 2013 · You would have to supply a lot of additional information about how to correctly use your class's constructors in a way that can be programmatically interpreted. Instead, the tools …

  6. Using 'this' keyword in Java constructors - Stack Overflow

    Feb 21, 2017 · I am confused with the this keyword in Java. If a class has two constructors and we use the this keyword in some method, the object represented by this is instantiated using …

  7. Constructor overloading in Java - best practice - Stack Overflow

    Constructors can be overloaded to create objects in different ways. The compiler differentiates constructors based on how many arguments are present in the constructor and other …

  8. Java Initialize an int array in a constructor - Stack Overflow

    This is because, in the constructor, you declared a local variable with the same name as an attribute. To allocate an integer array which all elements are initialized to zero, write this in the …

  9. Can a constructor in Java be private? - Stack Overflow

    May 12, 2010 · overloaded constructors - as a result of overloading methods and constructors, some may be private and some public. Especially in case when there is a non-public class that …

  10. How do I call one constructor from another in Java?

    Nov 12, 2008 · Calling a constructor from another constructor in Java is primarily a means of providing default values for parameters to the one constructor that should actually construct …