• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

packages and inhertance

 
Greenhorn
Posts: 13
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...

     
    Rancher
    Posts: 1043
    6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    thank you ivan.
     
    Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
    Free, earth friendly heat - from the CodeRanch trailboss
    https://www.kickstarter.com/projects/paulwheaton/free-heat
    reply
      Bookmark Topic Watch Topic
    • New Topic