i am always use static keyword but don't know clearly what is main purpose of static keyword. can any define , this is use in java Display method in oop
Asked
Active
Viewed 304 times
-6
-
class Display{ static void show(Animal c){ c.sound(); c.hair(); c.ears(); } } – Yasir Hussain Nov 26 '17 at 07:25
-
what is work of static in this class – Yasir Hussain Nov 26 '17 at 07:25
-
Read up : https://docs.oracle.com/javase/tutorial/java/javaOO/classvars.html – jrook Nov 26 '17 at 07:26
-
2You need to do some research on your own before asking a question here. There's countless online sources which explain what static is. – apokryfos Nov 26 '17 at 07:42
1 Answers
2
Static methods are those methods can be called without creating its object. It can be invoked using its class name.
Eg. Math.sqrt(25);
Where Math is the class name, not an object and static methods can access only static properties of the class.

Aman Vishnani
- 36
- 2