• Post Reply Bookmark Topic Watch Topic
  • New Topic

packages and inhertance  RSS feed

 
riteshhh kumar singh
Greenhorn
Posts: 13
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it mandatory to define both the superclass and derived class and the class with "main()" in same file.
i have created three classes named
  • protection.java,derived.java and samepackage.java.
  • in different files in package p1.
    Superclass "protection.java" is compiling successsfully but when i try to compile the derived class "derived.java" i get an error "cannot find symbol 'protection'" in "class derived extends protection".

    any help will be appreciated...

     
    Ivan Jozsef Balazs
    Rancher
    Posts: 999
    5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It is not mandatory. You can compile all sources at the same time.

    Or do this along these lines:

    javac -d compile_directory source1.java
    javac -classpath compile_directory -d compile_directory source2.java
    javac -classpath compile_directory -d compile_directory source3.java

     
    riteshhh kumar singh
    Greenhorn
    Posts: 13
    Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thank you ivan.
     
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!