difference between public private and protected in java
difference between public private and protected in java
Alibabacloud.com offers a wide variety of articles about difference between public private and protected in java, easily find your difference between public private and protected in java information here online.
The difference between private, protected, public, and default in Java1) for the public modifier, it has the most access rights and can access any class, interface, exception, etc. under Classpath. It is often used for external situations, i.e. the
Public, private, PROTECTE, default are the access rights that are used in Java to define the members, that is, without any permission modifiers before the members. Such as:public class a{void method () {};}Method belongs to the default
(1) for the public modifier, it has the most access rights and can access any class, interface, exception, etc. under Classpath. It is often used for external situations, i.e. the form of an interface to an object or class outside.(2) for the
(1) for the public modifier, it has the most access rights and can access any class, interface, exception, etc. under Classpath. It is often used for external situations, i.e. the form of an interface to an object or class outside.(2) for the
(1) for the public modifier, it has the most access rights and can access any class, interface, exception, etc. under Classpath. It is often used for external situations, i.e. the form of an interface to an object or class outside.(2) for the
(1) for the public modifier, it has the most access rights and can access any class, interface, exception, etc. under Classpath. It is often used for external situations, i.e. the form of an interface to an object or class outside.(2) for the
1, public:public indicates that the data member, the member function is open to all users, all users can directly make the call2, private:private means private, private means that except class himself, no one can directly use, private property
For the public modifier, it has the greatest access, and can access any class, interface, exception, and so on under Classpath. It is often used for external situations, i.e. the form of an interface to an object or class outside.
For the
(1) for the public modifier, it has the largest access and can access any one of the classes, interfaces, exceptions, and so on under Classpath. It is often used for external situations, i.e. the form of an interface to an object or class.
(2) for
Java supports four different kinds of access rights:
modifier
Description
Public
Common, visible to all classes.
Protected
Protected, visible to classes and all subclasses within the same
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.