What is static method? Why need to define as static? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

What is static method? Why need to define as static?

22nd Jul 2016, 11:58 PM
WPimpong
WPimpong - avatar
2 Respostas
+ 2
Static Method is a class method. It can be accessed by class name not by object. It gets initialized on loading itself. It allocates common memory for all.
23rd Jul 2016, 2:42 AM
Suga
+ 1
we have to define a method as static because it can access only static variables .
8th Aug 2016, 1:59 PM
Ambika Arora
Ambika Arora - avatar