About 181,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 …

  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 …

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

  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 …

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

  6. java - how to inherit Constructor from super class to sub class

    Oct 2, 2012 · 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 …

  7. How do I use optional parameters in Java? - Stack Overflow

    Update: Java 8 includes the class java.util.Optional out-of-the-box, so there is no need to use guava for this particular reason in Java 8. The method name is a bit different though. Builder …

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

  9. constructor of subclass in Java - Stack Overflow

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

  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 …