If you don't specify any parameters, it will allow you to call the method with anything as a parameter.
By putting void, you're telling it not to do that.
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState Compiler Development Forum
I can definitely see where the confusion comes from.
For function declarations in C, leaving nothing between parenthesis tells the compiler to not bother checking, meaning it'll take anything (bad idea!), so you need to pass void to explicitly tell the compiler that it takes nothing instead. I don't remember if newer versions of the language change this behavior to be like C++'s (see below).
In C++, leaving the parenthesis empty means exactly not taking any arguments (as if you had passed void).
In other words: welcome to some legacy quirk from old language implementations that stuck around for newer ones.
That "void" isn't a parameter. At any rate, what you're looking at are old-style declarations. Before C89 got standardized, C used to only work like this:
Sik wrote:I can definitely see where the confusion comes from.
For function declarations in C, leaving nothing between parenthesis tells the compiler to not bother checking, meaning it'll take anything (bad idea!), so you need to pass void to explicitly tell the compiler that it takes nothing instead. I don't remember if newer versions of the language change this behavior to be like C++'s (see below).
In C++, leaving the parenthesis empty means exactly not taking any arguments (as if you had passed void).
In other words: welcome to some legacy quirk from old language implementations that stuck around for newer ones.
EDIT: tl;dr include it to be safe.
Why is it a necessarily bad idea? It works either way.