Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extending my own class??

Status
Not open for further replies.

Vandy02

Programmer
Jan 7, 2003
151
US
I am trying to extend my own class. I am trying to extend 'DefaultLayout' into the Clone.java
I compile the DefaultLayout and run with no problems. When I try to compile the Clone.java I get....with an arrow at the semicolon. Does anyone have any idea how I can extend my own class?

'.' expected
import DefaultLayout;


==Clone.java

import DefaultLayout;

public class Clone extends DefaultLayout{

//No code at all here!!

} //end class def


==DefaultLayout.java

import java.awt.*;
import java.applet.*;

public class DefaultLayout extends Applet{

public void init(){
addComponents();
} // end init

public void addComponents(){
add(new Button("One"));
add(new Button("Two"));

} // end makeButtons
} // end DefaultLayout

Vandy
 
What package is DefaultLayout in ? If it is in the same package as your Clone class, then you should not "import" it. The same goes for if it is no package at all.

Otherwise you need to import the fully qualified name, ie ;

import com.test.DefaultLayout;
 
Hmmm....it is in the same package...I wonder why the book says to import it...???..Oh well..it works now

Thanks for the help though.
 
In SDK 1.3 and below, it was valid (though not necessary) to import "same package" classes. But in SDK 1.4 its not valid.

Why ? - dunno !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top