Link to home
Start Free TrialLog in
Avatar of exhuser
exhuser

asked on

Java: The Public Class Main

I am getting a compiler error " The public type "Main" must be defined in its own file"
Any suggestions?

public class Main {

    public static void main(String[] args)
SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dpearson
dpearson

It sounds like you have two public classes in the same file.

public class A {
}

public class B {      // Not allowed
}

Java doesn't allow that.  You either need to make Main private or move it to its own file.

Doug
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial