• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compile time errors

 
Venkat Ramsimha
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class MyOuter
{
public static void main(String args[])
{
System.out.println("hi");
}
public class MyInner
{
}
}

Hi All,
the above program is compiling fine even if we have more than one public class file?how come its possible?should compiler must not show compile time errors?
anybody please provide the solution

Thanks
venkat
 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The name of the class itself suggests one is outer and other is inner class.You can't have two top-level classes with public as the access modifier,but there's no problem as shown with your code...and so it compiles fine
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic