Static and Final of Java-from complete reference of Java

There will be times when you will want to define a class member that will be used independently of any object of that class. Normally a class member must be accessed only in conjunction with an object of its class. However, it is possible to create a member that can be used by itself, without reference to a specific instance. To create such a member, precede its declaration with the keywork static. When a member is declared static, it can be accessed before any objects of its class are created, and without reference to any object. You can declare both methods and variables to be static. The most common example of a static member is main(), main() is declared as static because it must be called before any objects exist.
Instance variables declared as static are, essentially, global variables. When objects of its class are declared, no copy of a static variable is made. Instead, all instances of the class share the same static variable.
Methods declared as static have several restrictions:
1.They can only call other static methods.
2.They must only access static data.
3.They cannot refer to this or super in any way.

Remeber: It is illegal to refer to any instance variables inside of a static method

A variable can be declared as fina. Doing so prevents its contents from being modified. This means that you initialize a final variable when it is declared.

想对作者说点什么? 我来说一句

Java The Complete Reference 10th Edition

2017年11月06日 110.33MB 下载

Java The Complete Reference(10th) epub

2017年10月13日 111.27MB 下载

Java The Complete Reference(10th) azw3

2017年10月13日 132.38MB 下载



Static and Final of Java-from complete reference of Java