Dark Horse programmer-permission modifier

Source: Internet
Author: User

------<a href= "http://www.itheima.com" target= "blank" >java training, Android training, iOS training,. NET training </a>, look forward to communicating with you! -------

The composition of the/** method:
* [permission modifier list] [other modifier list] return value data type method name (parameter list) {
* Operating body;
* return value;
*      }
*  *****!!!!! : Static variables and static methods:
* Except for private in this class can be called to use, in other classes are not
* In addition to default in the same package can, nothing else is not inherited also not
* Everything else, the Import guide class can then be called directly from the class name
*
*  *****!!!!! : member variables and member methods:
* Except private, which is not directly accessible externally, can be invoked in this class, not in any other class.
* Except default (default, there is no permission modifier defaults) inside the package modifier in the same package, nothing else can be inherited or not
* and then the protected (protected) inheritance modifier either in the same package, with the parent class reference to invoke, or there is a dependency on the premise of the subclass of the object reference to call directly, or can be seen as inheriting, (with the subclass reference to call, did not change the parent The permissions of the class, just called in the subclass)
* Access rights----------------static variables
* Public Private protected default
* Current Package the same class can be used to
*
* Other classes within the current package may not be able to
*
* Other classes in the bag may not be able to
*
* The class of your own package inheritance relationship may not be able to (v) can (v)
*
* Classes that inherit from other packages may not (V) not be able to (v)

*
* Static variables: Default cross-package is not possible, private can not
*
*
*----------------access rights for static methods
* Public Private protected default
* Current Package the same class can be used to
*
* Other classes within the current package may not be able to
*
* Other classes in the bag may not be able to
*
* The class of your own package inheritance relationship may not be able to (v) can (v)
* Classes that have inherited relationships from other packages may not be able to (V)
*
* Static method: Default cross-package is not possible, private can not
*
*
* PPP01 inherit from Teacher,ppp01 is it a teacher? So you can call the parent class directly, not with inheritance.
* Inheritance is inherited, call is called
* But PPP01 has a static variable and static method that is the same as the parent class, except that both the parent class and the subclass have a static variable with the same name and a static method, and inheritance doesn't matter.
* Parent class belongs to parent class, subclass of child class
* Call the parent class call is called the parent class, the subclass call is called the subclass of the bar, each irrelevant
*
* Who is invalid here: protected: inheritable access rights,
* Package Class permission still works
Access Rights----------------member variables
* Public Private protected default
* Current Package the same class can be used to
*
* Other classes within the current package may not be able to
*
* Other classes in the bag can not be no no no
*
* The class of your own package inheritance relationship may not be able to (v) can (v)
*
* Classes that inherit from other packages may not (V) not be able to (v)
*
* Protected: If you cross the package, you must have an inheritance relationship. Your package can be accessed directly without affecting
*
*
* Member variables: Default cross-package is not possible, protected main role is the other package has an inheritance relationship can be, their own package inheritance can not inherit
* Here's a point: When instantiating a subclass variable, you can access the member variables of the parent class, which is the value inheritable access
* If the object of the parent class is instantiated in a subclass, the access rights are not changed at this time
*
*
* Access rights for----------------member methods
* Public Private protected default
* Current Package the same class can be used to
*
* Other classes within the current package may not be able to
*
* Other classes in the bag can not be no no no
*
* The class of your own package inheritance relationship may not be able to (v) can (v)
* Classes that have inherited relationships from other packages may not be able to (V)
*
* Default: As long as the same package inside, do not inherit also can be instantiated access to, called in-Package access rights
* Protected: As long as there is a subclass of inheritance, we can access the parent class member variable and the member property by instantiating the child class
* Called Inherited access rights (as long as there is inheritance, not in this package can be)
* Inheritable access rights refer specifically to protected, which means that we instantiate subclasses and then access the properties of the parent class through subclasses, and that the subclass and parent class are not in a package or can
*
* Static variables and static methods,
*--1--: As long as it is static does not matter inherit or do not inherit, as long as can find can access, in addition to the default cross-package. Protected can also be accessed outside the package
*
*/

Dark Horse programmer-permission modifier

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.