如何用Java编写类名?
在编写类名称时,您需要牢记以下几点。
您不应使用预定义或现有的类名称作为当前类的名称。
您不应使用任何Java关键字作为类名(大小写相同)。
类名的首字母应为大写,其余字母应为小写(混合大小写)。
class Sample
同样,名称中每个单词的首字母应大写,其余字母应小。
class Test
建议使接口名称保持简单和描述性。
最好不要在编写类名时使用首字母缩写词。
示例
public class Test {
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 兄妹拍照祝福语简短的话