如何在 Java 中编写接口名称?
编写接口/类名称时,你需要记住以下几点。
- 接口/类名称的首字母应大写,其余字母应小写(混合大小写)。
interface Sample
- 同样,名称中每个单词的首字母都应大写,其余字母应小写。
interface MYInterface
- 建议保持接口名称简单且有描述性。
- 最好不要在编写接口/类名称时使用缩写词。
示例
interface MyInterface {
void sample();
void demo();
}
public class Test implements MyInterface {
public void sample() {
System.out.println("This is sample method");
}
public void demo() {
System.out.println("This is demo method");
}
public static void main(String args[]) {
Test obj = new Test();
obj.sample();
obj.demo();
}
}
输出
This is sample method This is demo method
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP