在编写方法名称时,我们应遵循驼峰式大小写,即,第一个单词的首字母应小写,其余(后来)单词的首字母应大写。
public class Test { public void sampleMethod() { System.out.println("This is sample method"); } public void demoMethod() { 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