Account of the class



Class is a package, members of a class can only be used within the class, the external need to "object name. Variable names" to refer to.
Correctly, local variables only define its code block or an internal function visible
member variable with the type, the need to specify objects to a reference
if the class is not constructor, the JVM will generate a default constructor, if the defined any type of construction method, The compiler will not automatically generated constructor.

 

Problem-solving points:

1, is a variable defined in the class member variable, other classes required to access the member variable to see the extent of access;

2, the method is only valid in the local variables defined;

3, using the methods of other classes, provided that, subject to the access, for static methods require the use of the class name to access the required reference to access to non-static methods through an object;

4, if the class is not defined in any of the constructor, the JVM will be the default constructor for the class constructor with no arguments.

Guess you like

Origin blog.csdn.net/weixin_44018338/article/details/91457324