About 10,400,000 results
Open links in new tab
  1. function - Purpose of a constructor in Java? - Stack Overflow

    Nov 13, 2013 · A constructor is used to create an instance of the class Card. And you'll need to call it 52 times to have 52 cards: new Card(1, "hearts"), etc. Now each instance of Player (you also need a …

  2. Java default constructor - Stack Overflow

    Dec 20, 2010 · What exactly is a default constructor — can you tell me which one of the following is a default constructor and what differentiates it from any other constructor? public Module() { this.name …

  3. class - Java :Setter Getter and constructor - Stack Overflow

    Jul 30, 2013 · My question is that if the constructor is the point of initialization and a default constructor is always present, why use a constructor with parameters to initialize values instead of …

  4. Static constructor methods in Java - Stack Overflow

    Feb 7, 2012 · Giving a class static methods that give you more control and gracefulness by returning instances of the class they are in is perfectly acceptable code. This is actually called the factory …

  5. Java: How can a constructor return a value? - Stack Overflow

    A constructor can not return a value because a constructor implicitly returns the reference ID of an object, and since a constructor is also a method and a method can't return more than one values.

  6. java - Can a class have no constructor? - Stack Overflow

    Dec 8, 2012 · Java does not actually require an explicit constructor in the class description. If you do not include a constructor, then the Java compiler will create a default constructor with an empty argument.

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

    I'm referring to both constructor overloading in a simple class and constructor overloading while inheriting an already overloaded class (meaning the base class has overloaded constructors).

  8. java - Why do this () and super () have to be the first statement in a ...

    Jul 23, 2009 · The parent class' constructor needs to be called before the subclass' constructor. This will ensure that if you call any methods on the parent class in your constructor, the parent class has …

  9. java - Why default constructor is required in a parent class if it has ...

    My understanding is that the default constructor is an implicit parameterless constructor. It is only automatically added to a class when no other constructors exist. This would indicate an …

  10. java - Setter methods or constructors - Stack Overflow

    Dec 21, 2016 · So far I have seen two approaches of setting a variable's value in Java. Sometimes a constructor with arguments is used, others setter methods are used to set the value of each variable. …