
是的,自Java9起,您可以在接口中使用私有方法。
软件介绍:金戈企业建站系统不仅是一份免费的企业建站代码包,而且它还是完全开源的,它倾注了作者1个多月来日日夜夜的心血,虽然有些地方没做到尽善尽美,可我相信在接下来的日子里我会通过反馈信息让她更丰满实用起来。1.完美的摸板机制,即使你对php一点也不懂,只要你会做网页。就可以立即打造新颖别致的网站界面(摸板制作方法手册正在紧张制作中,稍后发布)可惜作者精力有限,目前只提供一套摸板。不过只是暂时的2.
0
interface MyInterface {
public abstract void demo();
public default void defaultMethod() {
privateMethod();
staticPrivateMethod();
System.out.println("This is a default method of the interface");
}
public static void staticMethod() {
staticPrivateMethod();
System.out.println("This is a static method of the interface");
}
private void privateMethod(){
System.out.println("This is a private method of the interface");
}
private static void staticPrivateMethod(){
System.out.println("This is a static private method of the interface");
}
}
public class InterfaceMethodsExample implements MyInterface {
public void demo() {
System.out.println("Implementation of the demo method");
}
public static void main(String[] args){
InterfaceMethodsExample obj = new InterfaceMethodsExample();
obj.defaultMethod();
obj.demo();
MyInterface.staticMethod();
}
}This is a private method of the interface This is a static private method of the interface This is a default method of the interface Implementation of the demo method This is a static private method of the interface This is a static method of the interface
以上就是在Java 9中,我们可以在接口中使用私有方法吗?的详细内容,更多请关注php中文网其它相关文章!
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号