What is dot operator in Java?

Java 8Object Oriented ProgrammingProgramming

The (.) operator is also known as member operator it is used to access the member of a package or a class.

Example

public class Sample {
   void display() {
      double d = 20.3;
      int i = (int)d;
      System.out.println(i);
   }

   public static void main(String args[]) {
      Sample s = new Sample();
      s.display();
   }
}

Output

20
raja
Published on 12-Jan-2018 16:31:31
Advertisements