About 149,000 results
Open links in new tab
  1. 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 …

  2. Java default constructor - Stack Overflow

    Dec 20, 2010 · To make it explicite: if you write your own constructor, java will not create the default constructur. So if you need a constructor with arguments and a constructor without …

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

  4. java - How do I fast generate constructor and getter, setter in …

    Sep 11, 2023 · In Netbean, I can just use Ctrl + Space to fast generate Constructor, or right click and select insert code to get Constructor and Getter and Setter. How do you do that in VS Code?

  5. java - Creating an instance using the class name and calling ...

    Is there a way to create an instance of a particular class given the class name (dynamic) and pass parameters to its constructor. Something like: Object object = …

  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 …

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

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

  8. How to define custom exception class in Java, the easiest way?

    Sep 23, 2010 · 62 If you use the new class dialog in Eclipse you can just set the Superclass field to java.lang.Exception and check "Constructors from superclass" and it will generate the …

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

    Sep 25, 2013 · Empty constructor build GENERIC object, and constructor with parameters build objects with more specific information. Let’s say the example above, if I create an instance …

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

    Nov 4, 2008 · 76 Yes it can have a constructor and it is defined and behaves just like any other class's constructor. Except that abstract classes can't be directly instantiated, only extended, …