如何用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
热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短