I want to learn about static keyword plz somebody help | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

I want to learn about static keyword plz somebody help

5th Jul 2016, 6:59 AM
Abdul Rafay
Abdul Rafay - avatar
3 Respostas
+ 1
static members belong to the class instead of a specific instance. It means that only one instance of a static field exists even if you create a million instances of the class or you don't create any. It will be shared by all instances. Since static methods also do not belong to a specific instance, they can't refer to instance members (how would you know which instance Hello class you want to refer to?). static members can only refer to static members. Instance members can, of course access static members. Side note: Of course, static members can access instance members through an object reference. See http://stackoverflow.com/questions/413898/what-does-the-static-keyword-do-in-a-class
5th Jul 2016, 1:20 PM
AliƩnor Latour
AliƩnor Latour - avatar
+ 1
TheĀ static keywordĀ in java is used for memory management mainly. We can apply java static keyword with variables, methods, blocks and nested class. The static keyword belongs to the class than instance of the class. The static can be: - variable (also known as class variable) - method (also known as class method) - block - nested class
13th Aug 2016, 3:46 PM
WPimpong
WPimpong - avatar