How do I write method names in Java?

Java 8Object Oriented ProgrammingProgramming

While writing a method name we should follow the camel case i.e. first letter of the first word should be small and the first letters of the remaining (later) words should be capital.

Example

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();
   }
}

Output

This is sample method
This is demo method
raja
Published on 05-Jan-2018 14:18:25
Advertisements