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

  2. Can a constructor in Java be private? - Stack Overflow

    May 12, 2010 · overloaded constructors - as a result of overloading methods and constructors, some may be private and some public. Especially in case when there is a non-public class that you use in …

  3. java - How do you make a deep copy of an object? - Stack Overflow

    64 You can make a deep copy with serialization without creating files. Your object you wish to deep copy will need to implement serializable. If the class isn't final or can't be modified, extend the class and …

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

  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. constructor of subclass in Java - Stack Overflow

    Java provides you with a default constructor which takes no parameters. The constructor also has no body, so it is something like so: public Person() {}. The moment you define you own constructor, your …

  7. java - how to inherit Constructor from super class to sub class - Stack ...

    Feb 23, 2010 · You simply pass the arguments up the constructor chain, like method calls to super classes, but using super (...) which references the super-class constructor and passes in the given args.

  8. What is the use of making constructor private in a class?

    Jan 14, 2010 · It doesn't do any good to just mark the constructor private; a really determined user may always use reflection to obtain the constructor. Valid uses: One good use of a protected constructor …

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

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