In Java, if a method uses a static member, why should itself be declared as static? -


i understand in static method, non-static members should called related objects, or there ambiguity.

if understand correct?

in java, if method uses static member, why should declared static?

this not true - method uses static member not need static itself.

i understand in static method, non-static members should called related objects, or there ambiguity.

if understand correct?

no.

when member variable or method static, means member variable or method isn't part of, or doesn't work on 1 specific object of class; it's shared objects of class. section understanding class members in oracle's java tutorials explains in more detail.

non-static methods work on specific object, if call them static method, have call them on object, since there no current object (which this refers to) when you're in static method.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -