Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Accessing a protected method.

user10696492Dec 18 2008 — edited Dec 18 2008
Hello Java Gurus,

I have a question. I have a class which is having the protected method which is the method that is used to generate the result that I want to obtain(I have no idea why it is made protected as I think it should be public). Anyways !!! No I want to access that method(which is generating the result) into a class(this class is already extending one class) which is in another package without extending the class which contains the method(one generating the result).Is there any way to do this?

Let me explain it to you in this way

com.result(Package)

public Class GiveResult{
protected calculateResult(){...}
}

com.service(Second package)
public Class AccessResult extends SomeOtherClass{
// In this class I want to access calculateResult method from the GiveResult class.
}

I hope I have made myself clear.

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 15 2009
Added on Dec 18 2008
15 comments
436 views