接口03--静态方法

静态方法的使用就不能new了,而是直接使用

1.创建一个接口,里面有一个静态方法

public interface jingtai {

	public static void a() {
		System.out.println("这是一个静态方法!");
	}
}

2.使用

public class jingtai_shiyong {
public static void main(String[] args) {
	//正确写法:
	jingtai.a();

	//错误写法
// 创建了实现类对象
// MyInterfaceStaticImpl impl = new MyInterfaceStaticImpl();
// impl.methodStatic();

}
}
发布了28 篇原创文章 · 获赞 1 · 访问量 468

猜你喜欢

转载自blog.csdn.net/qq_45145809/article/details/105087352