Q:

How does 2 java classes that depend on each other compiles?

I have 2 classes ChatServer and ChatServerThread
public class ChatServer implements Runnable
{
    private ServerSocket     server = null;
    private Thread           thread = null;
    private ChatServerThread client = null;
}

and
public class ChatServerThread extends Thread
{
    private ChatServer       server    = null;
    private Socket           socket    = null;
    private int              ID        = -1;
    private DataInputStream  streamIn  =  null;
    private DataOutputStream streamOut = null;
}

How would these compile? If I want to write a build script which class would you compile first?

A:

Conceptually, the compiler makes two passes over each Java source file, the first pass to extract the external definitions (equivalent to an "include file") that are needed by other classes, the second pass to actually compile things and create the .class file.

