+ 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