aspose file tools*
The moose likes Java in General and the fly likes Package Inheritance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Package Inheritance" Watch "Package Inheritance" New topic
Author

Package Inheritance

vijay Krishnan
Greenhorn

Joined: Jul 27, 2006
Posts: 14
hi all,

i have a doubt on package concept.

That is, i have created the package in one directory and saved it.
Then, i have created the another one program and i tried to extend the
class which resides on the package.
but the package in one directory and the program or class is in another directory, and i used to extend that package class it displays some error.

CAN I DO That.

example:
********

package samp
{
class A
{

***
some STMT;
***

}
}

the above package saved in the directory called \vijay\

if i use the another one pgm by extending the A class it displays error.
i want to know the reason why it displays.



and also
in package class i declared the protected type data.

if i access that from the outside of that class, this also
displays the error as "cant access the data".

this also i want to know the reason why we cant access the
protected type on extended class?




Thanks & Regards,

Vijay
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14107
    
  16

Your description is not so clear, so I hope I'm explaining what you're asking.

Yes, you can create a package in one directory with a class in it, and write another class somewhere else (in a different program) that extends the class, as long as you put the first one on the classpath correctly.

What is "some error"? If you get an error, please copy & paste the exact error message in your post - the more precise you are, the better we can help you. Just saying "it displays some error" is too vague.

Things that are protected are accessible in subclasses and in classes in the same package.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Eddy Lee Sin Ti
Ranch Hand

Joined: Oct 06, 2005
Posts: 135
Hi vijay,

Can you post up your class implementation code? It might have something to do with the package accessibility.


SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="http://eddyleesinti.blogspot.com" target="_blank" rel="nofollow">http://eddyleesinti.blogspot.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Package Inheritance