About 51 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 Constructors - Stack Overflow

    Aug 21, 2016 · The constructor arguments allow you to provide parameters for the initialization of an object. In this example, you can create a Bicycle object with a gear of 1, cadence of 0, and a speed …

  3. Constructores en java - Stack Overflow en español

    Oct 6, 2016 · Hola amigos disculpen estoy estudiando java y en las clases el profesor tocó el tema de los "constructores java" y la verdad no entendí bien. Bueno lo que entendí es esto: Un constructor es

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

  5. Methods vs Constructors in Java - Stack Overflow

    Sep 27, 2013 · And you can tell a constructor from other methods because the constructor has the class name for its <method name> and has no declared <return type>. (In Java, of course, you create a …

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

    Instead of defining and calling a private constructor from all other constructors, you could also define an instance initializer, which will automatically be called before every constructor. That way, you won't …

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

    Nov 13, 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 your object, and …

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

  9. 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.

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

    Jul 23, 2009 · Java requires that if you call this() or super() in a constructor, it must be the first statement. Why? For example: public class MyClass { public MyClass(int x) {} } public class …