About 11,200,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. 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.

  4. 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 …

  5. java - Should I initialize variable within constructor or outside ...

    When I use Java based on my C++ knowledge, I love to initialize variable using the following way.

  6. java - Why call super () in a constructor? - Stack Overflow

    May 9, 2012 · 0 as constructor is not a part of class, so while calling it cannot be implemented, by using SUPER () we can call the members and memberfunctions in constructor.

  7. Do I really need to define default constructor in java?

    Jan 10, 2017 · A default (no-argument) constructor is automatically created only when you do not define any constructor yourself. If you need two constructors, one with arguments and one without, you …

  8. java - Copy constructors and defensive copying - Stack Overflow

    Feb 22, 2013 · java java.awt.Point and Rectangle come to mind; also very old, mutable objects. By using immutable objects, like String, or BigDecimal, simply assigning the object reference will do. In fact, …

  9. java - How can I access a private constructor of a class ... - Stack ...

    Apr 8, 2010 · The basic premise for having a private constructor is that having a private constructor restricts the access of code other than own class' code from making objects of that class.

  10. super() in Java - Stack Overflow

    Sep 22, 2010 · 1 Just super (); alone will call the default constructor, if it exists of a class's superclass. But you must explicitly write the default constructor yourself. If you don't a Java will generate one for …