• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

problem with inhereitance

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class Text1 {
public Text1()
{
}
String text = "Why is there air?";
public String getText() {
return text;
}
}
public class Text2 extends Text1 {
public static void main(String[] args) {
Text2 t2 = new Text2();
System.out.println(t2.getText());
}
}
when compling Text2 getting error
C:\padma\test\Text2.java:1: Superclass Text1 of class Text2 not found.
public class Text2 extends Text1 {
^
1 error
Process completed with exit code 1
is their anything i am missing.
please help me in this
with regards.
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check two things.
1. Did you compile Text1 first? You must.
2. Make sure your classpath is set to include the location of your class files.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try changing the first line of your code by eliminating the class modifier: public. It should then read...
class Text1 {
Someone else will have to explain the rationale.
 
Sheriff
Posts: 9103
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From java.sun.com/docs/codeconv/html/CodeConventions.doc2.html
Each Java source file contains a single public class or interface.
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic