+ 4

Explain dot operators in simple words

With example

11th Jul 2021, 5:46 AM
š“š“·š“¼š“±š“²š““š“Ŗ (Anshika)
š“š“·š“¼š“±š“²š““š“Ŗ (Anshika) - avatar
3 Answers
+ 9
The dot operator, also known as separator or period used to separate a variable or method from a reference variable. Only static variables or methods can be accessed using class name. 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(); } }
19th Oct 2021, 8:39 AM
Vaibhav
Vaibhav - avatar
+ 6
I think this is the easy explanation, given by tutorialpoint 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
11th Jul 2021, 5:51 AM
Abhiyantā
Abhiyantā - avatar