In java is there a way to make a class implementing the interface methods to private?
Something like this:
class A implement interface1
{
//make this private
public void test()
{
}
}
No . You can't change the access modifier of a method you're implementing from an interface. Because, the resulting Object
would no longer implement the interface.
Methods in Interface are defined public
. It's cannot be private
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.