What do empty curly braces / curly braces mean in Java?

Here is the whole source code:

http://zerioh.tripod.com/ressources/sockets.html

Here is the code I want to highlight:

Provider(){} 

What does this line mean? Thank you

+6
source share
4 answers

This means that nothing is done in this constructor. Typically, Java provides this by default, so provider () {} is not required.

The main difference between this and the default provided by the compiler is that access is limited because it is not publicly available.

+4
source

This is a constructor with standard availability.

+1
source

The no-arg constructor is simply defined instead of being undeclared. However, since the "public" access level modifier was not taken into account, this means that the no-arg constructor is defined using the default package.

This means that any classes outside the package cannot create it. Only classes within the package can instantiate the Provider class.

+1
source

This is the default constructor that does nothing.

An object of this class can be created with a package.

0
source

Source: https://habr.com/ru/post/909607/


All Articles