+ 4

Explain dot operators in simple words

With example

11th Jul 2021, 5:46 AM
đ“đ“·đ“Œđ“±đ“Č𝓮đ“Ș (Anshika)
đ“đ“·đ“Œđ“±đ“Č𝓮đ“Ș (Anshika) - avatar
3 Respostas
+ 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