Java Static

Java Static,第1张

Java Static Static Class Variable

If a variable X of a class C is flagged as static, there will be only one copy of X no matter how many instances of C are created. Like a global variable.

Static variable exists from the start of the execution of the program, before any instances of any classes have been constructed.

Static Class Method

Static class methods – may be contrasted with other methods of the class which are called member methods

Member vs. Class

  • Member methods can only be invoked on instances of the class; static methods may be invoked on instances or may be called even if we don’t have an instance of the class at hand.
  • Static methods only refer to static variables of the class, not ordinary (member) variables; member methods of the class may refer to both the static variables as well as the member variables of the class

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4670627.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-07
下一篇2022-11-06

发表评论

登录后才能评论

评论列表(0条)

    保存