[Mono-list] Real noob question!

Eric Damron edamron@spamcop.net
Tue, 19 Oct 2004 20:36:54 -0700

Okay, I've been doing everything wrong.  I've been trying to put some of 
my program logic into the main method of one of my classes and have been 
fighting it all the way!

What is the correct way to structure the class that kicks off the whole 
thing?  Are you really suppose to create an instance of the class within 
the class itself??

public class foo
    int somevariables;
    AnotherClass   anotherClass   = new AnotherClass();

    public foo()
       // this is a constructor

    private foo2()
       // this is a method of class foo

    static void main()
       // here is where I get into trouble
       foo f = new foo();   // Instanating a class within itself is too 

Since everything seems to have to be inside a class, the code that must 
first execute must also be in a class but how can it execute unless 
there is an instance of the class?  How can there be an instance of the 
class if no code can execute???  It's the chicken or the egg problem!