How do I write interface names in Java?

Java 8Object Oriented ProgrammingProgramming

While writing an interface/class names you need to keep the following points in mind.

  • First letter of the interface/class name should be capital and remaining letters should be small (mixed case).
interface Sample
  • Likewise, first letter of each word in the name should be capital an remaining letters should be small.
interface MYInterface
  • Keeping interface names simple and descriptive is suggestable.
  • Better not to use acronyms while writing interface/class names.

Example

Live Demo

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

Output

This is sample method
This is demo method
raja
Published on 05-Jan-2018 10:17:30
Advertisements