About 103,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 important …

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

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

  4. java - How can I access a private constructor of a class ... - Stack ...

    Apr 8, 2010 · The basic premise for having a private constructor is that having a private constructor restricts the access of code other than own class' code from making objects of that class.

  5. java - Constructor in an Interface? - Stack Overflow

    An interface does not have an instanced implementation, hence no constructor. The use case you describe is akin to an abstract class in which the constructor calls a method of an abstract method …

  6. Best way to handle multiple constructors in Java

    I've been wondering what the best (i.e. cleanest/safest/most efficient) way of handling multiple constructors in Java is? Especially when in one or more constructors not all fields are specified: ...

  7. What is the purpose of a no-arg constructor? - Stack Overflow

    A constructor with or without parameters has a purpose of creating in object in order to access the methods in its class. With the no parameter constructor, you are able to create the object in order to …

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

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