C's (and C++'s) compilation model is designed so that compilers can operate without having to look at the entire program's code-base, or indeed to read through any given source file (really, any
translation unit) more than once. C's an old language, and it's designed with constraints that don't usually apply on modern development machines.
Java only has source files - the compiler doesn't need to be told about things before they are used. C and C++ don't work that way, so header files are required to tell the compiler about (declare) things that aren't defined in the translation unit being processed.
In C++, we wouldn't make a pure function named
max() a member of a class. That's plainly bad design. If we ignored that issue and did it anyways, we still wouldn't write a constructor for that class. You
would need a declaration of that
max() function before it was used, however; that would go in the header file, which other source files could copy/paste in through an
#include preprocessor directive.
The Swing source code can be found in your copy of the JDK.
Or, online:
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/javax/swing/