• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

problem with inhereitance

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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: 9099
12
  • Mark post as helpful
  • send pies
  • 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.
 
Roses are red, violets are blue. Some poems rhyme and some don't. And some poems are a tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic