+ 1

Static methods are called by the class name a dot followed by the method name for example Calculation.add(2,4);

But sometime it also works without the class name for example System.out.println(add(2,4)); Why please somebody explain.

2nd Jul 2019, 7:42 AM
stephen haokip
stephen haokip - avatar
1 Odpowiedź
+ 4
you'll need the class name if the method are called from another class. but if its called from the same class, its fine to not to include the class name.
2nd Jul 2019, 7:54 AM
Taste
Taste - avatar