static properties;Final -The ultimate1, modifier class-The final class, the class cannot be inherited (the purpose is that the class can not be extended, that is, cannot be changed);2, the modification method-the final method, the method can not be overridden by the quilt class
Public/protected/private
Public means open, private for privacy, protected for protection, nothing written for default defaults.
Method:
Public protected Default Private
√√√√ in the same class
√√√x in the same package
In the √√xx subclass
√xxx in different packages
Member Variable:
Consider the security and robustness issues, member variables are generally private, and provide some public methods to modify the member variables, in the modifi
.
If a class is final, all methods in the class are final.
Expansion and Promotion:
Static,final and abstract are not able to modify the construction method
Class loading
Concept: When the JVM uses a class for the 1th time, it first finds the corresponding.
There are only three access modifiers public,protected and private in Java.
1, if you do not write any modifiers, the default is "package access permissions." The equivalent of all other classes and methods within the package is public, and the classes and methods outside the package are private. Because the grace of a compilation unit (a
has been the concept of these modifiers is not very clear, while the intern assessment just ended empty time to study.1. Modifiers that can modify member variables and member methods have three plus one default. Their scope uses the following:Scope Current class same package descendant class other packagePublic√√√√Prot
Modifiers in the Java language----------------------------------------------------------------------------------------------The available modifiers for classes, methods, member variables, and local variablesAccess Control Level classifications:Exposure level, protected level, default level, private level------------------------------------------------------------
The member variables of a Java class typically have the following access modifiers:
Public, private, protected, or default,
For example, in package first, if there is a class FirstClass with four variables:
public int pp;
private int Xiaopp;
protected int DD;
int xiaodd;
If there is another
The permission modifiers in the 1.Java language mainly include private,public, default, Protected, which control access to member variables and member methods of classes and classes . permission modifiers in the Java languageSyntax formatting when modifying a variable with a permission modifier:Puclic type attribute
class* 3) a large:* 3.1) The subclass method has access rights greater than or equal to the parent class's*/The parent class is large, the sub-class is smallClass coo{void Show () {}Double Test () {return 0.0;}Doo Sayhi () {return null;}Public Coo Say () {return null;}}Class Doo extends coo{int Show () {return 1;}//Co
In Java classes, we often see static keywords, which are often referred to as statics. The static modifier can be used to decorate a data member, a method member, but not a class (this refers to an external class) and cannot modify a construction method. For example,
package com.csst.vo; public class User { priv
Differences between the four access modifiers in java and detailed explanation of the entire process
Client programmers: class consumers who use data types in their applications. Their goal is to collect various classes for fast application development.
Class Creator: A programmer who creates a new data type. The goal
1, Java has four access modifiers: default/public/private/protected2, they have different access rights, and in different situations and have different access rights, divided into the following several{1, the same kind of{First we write a piece of code to test{
Class Boar
{
void Defmethod ()
{
System.out.println ("default method");
}
p
Differences between java files generated by using modifiers repeated, required, and optional in protobuf's original configuration file. proto
Recently, I am working on a Netty-based framework project.
This project uses Google's Protobuf as the codec framework. (XML or json is not used to improve efficiency ).
After a period of time, I made a simple summary of the original Protobuf files.
Here I will mainly
public access is not restricted.-----------------------------------------------Special Note: In C # If the class internal members (methods, properties, fields, etc.) do not write any adornments Fuzeme think private;The default is internal if the access modifier of the Class (class) is not written.Assemblies can be understood as current projects, such as when bui
)Package com.zq.demo.test1;/*** In-Class* @author Administrator*/public class Person {Public String uname = "Harry";public void Introducemyself () {System.out.println (uname);}}Package com.zq.demo.test1;Same packagepublic class Student {Person p = new person ();public void Test () {System.out.println (P.uname);}}Package com.zq.demo.test1;Sub-classpublic
implementation of the method is provided by the subclass.Abstract methods cannot be declared as final and abstractAny subclass that inherits an abstract class must implement all the abstract methods of the parent class, unless the subclass is also an abstract classIf a class contains abstract methods, then the class m
Access modifiersThere are four access rights in Java, and when different access rights are used, the modified content has different access rights, and the following table describes the ability to access different permissions:Public protected Default Private√√√√ in the same classIn the same package (subclass and unrelated classes) √√√Sub-class √√ of different packagesUnrelated classes in different packages Y
returned type must always be the same as the return type of the overridden method, otherwise it cannot be called overriding but overloaded. (3), the restriction of the access modifier must be greater than or equal to the access modifier of the overridden method ( Public>protected>default>Private) (4), the overriding method must not throw a new check exception or a more generalized check exception than the overridden method declaration. For example: A method of the parent
Description of the meanings of the access modifiers public, private, protecte, and default in Java:Public (interface access permission): modifier with the widest access restriction in Java, which is generally called "public ". Classes, attributes, and Methods Modified by the package can be accessed not only across classes, but also across packages.Private (you cannot access): the shortest modifier in
There are four access modifiers in Java: public,protected,default,privateNote: This is about access to the properties and methods in the class, not the access rights of the class1.default: Package access rightsIf nothing is written, default defaults. Of course, you can also explicitly give the default permissionThe properties and methods of the default adornment,
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.