[Solved] When to use blank parameters in Java? [closed]


You’d use them when you don’t need to give the constructor or method any data. In the case of your ArrayList it’s to make an empty array with a default capacity of 10 elements (OpenJDK implementation).

As an abstract example, I can tell you to eat() but I don’t care what you eat, so I don’t tell you what to eat. (in the case of a method)

Or I can make a new Bookshelf() but I don’t have any books, so I don’t tell it anything, I just need an empty bookshelf. (in the case of a no-args constructor)

solved When to use blank parameters in Java? [closed]