, asked
Views : 2

What is dot operator in Java?

What is dot operator in Java?

1 Answer
Sai Subramanyam

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

Advertisements
Related Questions