public classes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rameshkumarc
    New Member
    • Jan 2007
    • 14

    public classes

    plz clear me y two public classes are not allowed in a single java file
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    Originally posted by rameshkumarc
    plz clear me y two public classes are not allowed in a single java file
    if a .java file contains a public class, e.g.
    Code:
    public class Test1
    the name of the file must be the same as the class, i.e. in this case Test1.java

    hence you cannot have two public class definitions in the same .java file

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      i alse don't understand that
      plz give me the solution.....

      thanks in advance

      Comment

      • JavaStudent07
        New Member
        • Jan 2007
        • 64

        #4
        :) lol, DO THE WORK FOR ME JEEZ! lol...you could probably import a java file like the project i'm working on, run a program inside a program but you cant(as far as I know, im not very good at this) put two programs in one with separate class headers.

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by dmjpro
          i alse don\'t understand that

          plz give me the solution.....



          thanks in advance
          Which part do you not understand?

          If you have a public class in a file, the name of that class must match the name of that file. That is what horace said.

          Comment

          Working...