Alibabacloud.com offers a wide variety of articles about java class access modifiers, easily find your java class access modifiers information here online.
The modifiers in Java have not been remembered, now combined with some information on the web to summarize, and focus on the protected modifier.I. Access modifiers in JavaOne of the basic concepts of Java object-oriented is to encapsulate the details and expose the interface
Label:Access levels
Modifier
Class
Package
Subclass
World
Public
Y
Y
Y
Y
Protected
Y
Y
Y
N
No modifier
Y
Y
N
N
Private
Y
N
N
N
The following table shows where the members of the Alpha class is visi
Local inner class features:1. A class defined in a code block or method body is called a local inner class2. The local inner class accesses the properties and methods of the external class using the "external class name." This. The name of the property and the external
Basic Java syntax (1) ---- keywords Identifiers (Java language identifiers naming rules Java language package name, class name, Interface Name, variable name, function name, constant name naming rules), java basic syntax
I. Keywords
Keyword definition and features
Definiti
access Rights ControlJava provides access modifiers for class library developers to indicate to the client programmer what is available and what is not. The level of access control, from the maximum permissions to the minimum permissions are: Public, protected, package
Chapter Sixth Introduction to access rights controlJava provides access modifiers that the class library developer can use to indicate to the client programmer what is available and what is not. The level of access control, from maximum permissions to minimum permissions, is
1. ParsingJava has four access rights, three of which have access modifiers, private,public and protected, and one without any modifiers.
The narrowest modifier for access restrictions in the Private:java language is generally referred to as "private." Classes, prop
gdestination (string whereto ){Label = whereto;}Public String readlabel (){Return label;}}
Public destination DEST (string s ){Return new gdestination (s );}Public contents cont (){Return new content ();}}
Class testgoods {Public static void main (string [] ARGs ){Goods P = new goods ();Contents c = P. cont ();Destination d = P. DEST ("Beijing ");}} Java multi-thread synchronized Guide
In this example
. println ("name:" + getName () + "Age:" + getAge () + "Salary:" + getMoney ());}} public class ABSDemo01 {public static void main (String [] args) {Student s = new Student (10, "James", 100); s. want (); Worker w = new Worker (35, "Ming", 1000); w. want ();}}
Analyze the above Code:
The above code overwrites the constructor public Person (int age, String name) in the parent class ). If the sub-
. HelloWorld3. Access between classes under different packagesPackage cn;/** * Summation */public class Demo {public int sum (int a,int b) {return a + B;}}Package com;/** * Tests */public class Test {public static void main (string[] args) {CN. Demo d = new CN. Demo ();//It's too much trouble. System.out.println (D.sum (1, 2));}}4. Guide PackageGuide Package Over
in Java? ------Field Table Field_info structure definitionfor the above field representation, theJVM Virtual Machine specification Specifies the field_info struct to describe the field, which represents the following information:Here I will explain the constituent elements of Field_info : The Access flag (access_flags), the name Index (name_index), the description index (descriptor_ Index), property sheet
Public interface contents { Int value (); } Public interface destination { String readlabel (); } Public class goods { Private class content implements contents { Private int I = 11; Public int value (){ Return I; } } Protected class gdestination implements destination { Private string label; Private gdestination (string whereto ){ Label = whereto;
Why do you design access control mechanisms in Java? The main function has two points:
(1) In order for the user not to touch the parts that they should not touch, these parts are necessary for the internal operation of the class, but it is not part of the interface required by the client programmer.
(2) To allow class
the inner class is actually a class that also contains another classAs a person is composed of body results, such as the brain, limbs, organs, and the inner class is equivalent to one of the organs, such as the heart: it also has its own properties and behavior (blood, beating) obviously, here can not unilaterally use properties or methods to express a heart, but
question)* First line of package, import second, class third4. Common modifiers used by the class and its composition* A: modifier:* Permission modifier: private, Default (Defalut), protected,public* Status modifier: static,final* Abstract modifier: Abstraction* B: Class:* Permission modifier: default modifier, public
JAVA class summary, java class SummaryJAVA class Summary
I recently read some content related to java internal classes and made some summary. Released in sync with my blog zhiheng. me. Title:
membersinterface because of its particularity, all members of the access rights are defined, the following is the access rights of the interface members:
variable: public static final
Method: Public abstract
internal class, internal interface: public static
And because everything is mandatory by default, so when we use it, we don't necessar
, including C,c++,fortran, assembly language, etc.Four. Access control for class members :That is, the method of the class and the access control of the member variable, a class that is not visible as a whole object, does not mean that all his fields and methods are not visi
;Protected int getMoney (){Return money;}Void setMoney (int newMoney){Money = newMoney;}}Son. javaPackage com. bbbImport com. aaa. Father;Public class Son extends Father{Void f (){Money = 10000; // valid// Height = 170; // invalid. The height is a variable modified by friendly.System. out. println (money); // The output result is 10000.// SetMoney (300); // invalidInt number = getMoney (); // validSystem. out. println (number); // The output result is
Access level of the class:Class access level is like a tree, want to reach the top of the tree, to climb slowly from under the tree. The branches under the tree can see the branches next to them. In Java, the methods of a class also have a level relationship.Public access le
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.