• 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
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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: 9109
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.
 
Forget Steve. Look at this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic