user2336315
user2336315

Reputation: 16067

Why not a private no args constructor?

Looking at the ArrayUtils class from apache commons, the doc says :

ArrayUtils() 

ArrayUtils instances should NOT be constructed in standard programming.

I was looking at the source code of this class, and I saw they made the constructor public :

public ArrayUtils() {
   super();
}

Since all the methods/fields of the class are static, I understand that it makes no sense to create an instance of this class.

So why don't they made the constructor private like in the Math class to avoid creation of new instances?

Upvotes: 7

Views: 607

Answers (1)

Neeraj Krishna
Neeraj Krishna

Reputation: 1615

The documentation says:

This constructor is public to permit tools that require a JavaBean instance to operate.

Upvotes: 10

Related Questions