
-----------------------------------
eNc
Wed Oct 12, 2005 2:04 pm

Multiple Classes
-----------------------------------
How can I have 2 files, 1 with a class containing my main method, and then the other with an object class, and then using my main method file to create a new object which is defined in the other file.

-----------------------------------
wtd
Wed Oct 12, 2005 4:05 pm


-----------------------------------
An example.

In "Foo.java":

public class Foo
{
   private int bar;

   public Foo(int initBar)
   {
      bar = initBar;
   }

   public String toString()
   {
      return Integer.toString(bar);
   }
}

And in "Main.java":

public class Main
{
   public static void main(String

As long as both are in the same directory, that just works.

-----------------------------------
eNc
Wed Oct 12, 2005 6:22 pm


-----------------------------------
thanks wtd, i just wasn't sure if you could do that.
