There are four types of access modifiers in Java, private, default, protected, public, and their access rights are raised sequentially, and private can only be called by this class. The default, which defaults to not write, can be called by all classes under the same package, and protected can be called by all classes under the same package, or by subclasses unde
The meaning of the access modifier in Java, public, private, PROTECTE, default, is explained:The most restrictive modifier in the Public:java language, commonly referred to as "public". Classes, properties, and methods that are modified by it are notCan be accessed only across classes, and across packages (package).The narrowest modifier for access restrictions in the Private:java language is generally referred to as "private." The classes, attributes
* Declaration of the class
[Modifier] Class
Modifiers: optional, for specifying access rights, the available values are public,abstract and finnal.
Class name: In general, the first letter is required to be capitalized.
Extends parent class name: optional, which specifi
Compared to C + + in public,proctected, private three access control, Java more than the default access control.Four types of access control permissions in Java are described briefly as four sentences:1) Private only this class is visible (same as C + +)2) default to this package visible/in-package access (C + + not)3) Protected is visible to this package and all
The protected methods and properties defined in a class are the same as the default permission methods and properties. For example, a class of protected methods and properties outside the package is not accessible through the class instance (can you access the default permissions of a class outside of the package metho
Access modifiers are typically used to modify properties and methods in a class, to constrain access to properties and methods;
Public//This class, the same package, sub-category, others can access;
protected//This class, the same package, the subclass can access, other can not access;
Private//Only this
The concept and function of packageConcept:----is physically a folder----Logically a collection of logically related classesRole:----Avoid class names----Controlling access rightsNaming conventions:-----First level refers to the type of the project, such as com,org,gov, etc.------The second level refers to the company name that the project develops or runs, such as: Chinasofti,icss,huawei, etc.-----The third level refers to the name of the project, su
//Math.sin (12.34); //Math.tan (12.34); //... //exponential function//Math.exp (12.34); //Math.log (12.34); //... //Rounding method, rounding up , rounding up and rounding downSystem.out.println (Math.rint (12.74));//Who are you close to?System.out.println (Math.floor (12.74));//take the smallest integerSystem.out.println (Math.ceil (12.34));//take maximum integerSystem.out.println (Math.Round (12.34));//serious rounding, returns a long integerSystem.out.println (Math.min (
all the methods in the abstract class are implemented, or it is still an abstract class.B, Interface (interface)1.Interface Definition: A collection of abstract methods and constant values (all methods are abstract methods). It is a special kind of abstract class (a Xxx.class file is generated and the compiler automaticallyInterface KeywordsBefore addingAbstract)。2.features:A, in the interfaceConstantsBy d
When developing internal projects or individual modules (Non-public modules), the use of the modifiers on access rights may not be very noticeable, but access modifiers are important in the writing of public code or the development of an SDK class. The following is an understanding of public,protected,default,private, providing a way to:1. If it involves the invo
Access modifier permissions from high to low are public, protected, default, Private.First, according to "whether is the same package", "whether is sub-category" divided into 4 cases + 5 cases of this type Second, the sub-class in the same package and non-subclasses in the same package are merged into the same package
Access modifiers
This class
Four access modifiers in Java:Public (publicly), protected (protected), default, Private (proprietary).They determine the scope of what is immediately followed by what is defined.The smaller the scope Access Rights class Bun class other packagesPublic∨∨∨∨ (available to anyone)Protect∨∨∨x (other classes within the same package and inherited classes can be accessed
The 1.readonly modifier is used only to decorate a data member of a class. As the name says, once they have been written, directly initialized, or assigned in a constructor, the data member can only read it.The difference between a readonly and a const data member is that const requires you to initialize it directly at the time of declaration.classMyClass {Const intConstint = -;//Proceed directly ReadOnly intMyInt =5;//Proceed directly ReadOnly
In Java's interface, the default modifier for member variables is: public static finalSo when we define member variables in the interface, we can1:public static final String name = "Zhang San";2:string name = "Zhang San";Both of the above can be, the old driver is generally the second kind. Since it is a static final variable, it means that you cannot modify the value of this member variable while accessing it outside. Therefore, defining member variables in an interface is generally constant. i
Public this class and not the class can be accessedPrivate only the class can accessProtected members of the class and its subclasses can access it, and the classes in the same package can also accessClasses in the same packet by default can accessSubclasses override the method of the parent
An understanding of possessive number modifiers in Java regular expressions the regular expression for the number qualifier such as, +, *, {n, m} matches by default is greedy mode, for example: a.*b match acbab result is acbab instead of ACB regular expression support lazy mode, That is, add a number modifier (quantifier) to the number qualifier, with a question mark, such as: A.*?b matches the acbab result
In Java's interface, the default modifier for member variables is: public static finalSo when we define member variables in the interface, we can1:public static final String name = "Zhang San";2:string name = "Zhang San";Both of the above can be, the old driver is generally the second kind. Since it is a static final variable, it means that you cannot modify the value of this member variable while accessing it outside. Therefore, defining member variables in an interface is generally constant. i
Keyword A total of four, from small to large are private protected public there is a default permissionPublic can be accessed from all locationsPrivate can only be accessed in this class and internal classesEasy to confuse is protected and the default access rights1. Protected and default access rights are visible in the same class as the packagePackages are not the same when protected in subclasses, and th
Permissions are as follows:
No.
Range
Private
Default
Protected
Public
1
The same class under the same package
√
√
√
√
2
different classes under the same package
x
√
√
√
3
subclasses under different packages
x
x
√
√
4
Non-s
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.