Is it OK to write a constructor which does nothing?

constructor, java, oop

Solution

You don't need to write an empty contstructor; the Java compiler will automatically insert one for you (only if you haven't defined any other constructors that take some args).

So it's quite okay (and useful in some situations) but it's not required.

Problem

To use methods of a class I need to instantiate a class. At the moment the class has not constructor (so I want to write it). But than I have realized that the constructor should do nothing (I do need to specify values of fields). In this context I have a question if it is OK to write constructor which does nothing. For example: ``` public Point() { } ```

Original source