About 50 results
Open links in new tab
  1. Java Constructors - Stack Overflow

    Aug 21, 2016 · I am trying to learn how to specify class constructors in Java. I am starting to understand that they specify the types of instance variables of objects made from that class. They also can be …

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

  3. Java default constructor - Stack Overflow

    Dec 20, 2010 · The form of the default constructor for a top level class, member class, or local class is as follows: The default constructor has the same access modifier as the class, unless the class lacks …

  4. super () in Java - Stack Overflow

    Sep 22, 2010 · super() can be used within a constructor to call the constructor of the parent class. OK, now let’s practically implement these points of super(). Check out the difference between program 1 …

  5. class - Java Constructors - how to create them - Stack Overflow

    Jul 26, 2020 · In Java, a constructor is a block of codes similar to the method. It is called when an instance of the class is created. At the time of calling constructor, memory for the object is allocated …

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

  7. Java Record custom constructor - Stack Overflow

    Dec 2, 2021 · A record class has the following mandated members: a canonical constructor, which must provide at least as much access as the record class and whose descriptor is the same as the record …

  8. java - Calling constructor of a generic type - Stack Overflow

    Consequently, instantiating a Java class of a parameterized type is impossible because instantiation requires a call to a constructor, which is unavailable if the type is unknown. You can go around this …

  9. Java Reflection: how can you get constructor of a class you don't know ...

    Mar 21, 2022 · 0 Let's say you're making a general reflection class. You're given the name of the class in string format: So you do Class.forName (class_name) to get the class name. Next step would be to …

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