Hi there.
I want to create my own File class to work easier with files.
Is it possible to inherit for example only file.exists from java file class not every methods?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi there.
I want to create my own File class to work easier with files.
Is it possible to inherit for example only file.exists from java file class not every methods?
Why would you want to do that? That doesn't make sense to me.
You can't reduce the visibility of inherited methods in subclasses. It doesn't make sense to castrate classes. Your only chance is to reimplement only those methods you need.
Please read the Announcement at the top of the sub-Forums to learn how to post your code in code/formatting tags and how to ask questions that get attention and receive helpful answers.
Nonsensical response.Because of code encapsulation.
Inherited methods can be overridden, either rewritten to perform a different function entirely or to simply "zero them out." I'm not suggesting you do this, but you could experiment with "cascading inheritance," to see if you can achieve the desired result.