Discover java class private variables, include the articles, news, trends, analysis and practical advice about java class private variables on alibabacloud.com
Go to: variables referenced by Java objects and objects, and variables referenced by java objectsJava object and its reference
Some basic concepts about objects and references.
When I was a beginner in Java, I thought the basic concepts were vague for a long time. Later, I l
Tag: Cannot perform reflection ring PAC his private SSE constructorWe all know that using Java reflection can dynamically change the behavior of an object at run time, even private final member variables, but not all cases, you can modify the member variable. Give a few small examples today.
Basic data types
To make a distinction between the two brothers, first of all, we need to know what they are respectively. First the knife from the member variable.
Member variable
We're going to look at one thing:
Attributes: External characteristics, such as human height, weight
Behavior: The ability to do something, such as talking, playing, etc.
In the Java language, the most basic unit is the class, and the
CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> Class Song@ Plays = 0 Def Initialize (name, artist, duration)@ Name = Name@ Artist = Artist@ Duration = Duration@ Plays = 0End Def Play@ Plays + = 1 # Same as @ plays = @ plays + 1 @ Plays + = 1 " This song: # @ plays. Total # @ plays. " EndEnd
For debugging purposes, I specifically return a string containing the number of times the song was played and
In Java, the three reserved words are used to modify the data members and member functions of the class, and the class itself. In C ++, the data members and member functions of the modifier class, and the inheritance of the class, but you don't need to modify the
The inner classes can be static (static) and can use public, protected, and private access controls, while external classes can use only public, or default.A class that is directly defined within a member's inner class (not inside a method or inside a code block) is a member inner class that can directly use all the
Internal classClass within the class1. Solve multiple inheritance2. resolves conflicts between methods during inheritance and interface implementation3. Data HidingOnly internal classes can have four types of access ModifiersWhen the internal class is private, an external class provides methods to access the internal class
marks, Japanese and other language and escape characters), such as: a but AB multi-character is not;
Boolean: boolean
Reference data types: class, interface, and array
The class has a very common type: String is a String type. It is a defined class in Java and can be directly used.
Calculation between
Java reads system attributes and environment variables, and java environment variables
Sometimes, when writing an application, you need to write data files and log files to the file system. In this case, you need to determine the operating system type and the current user's home directory to standardize file writing, e
[JAVA] final variables that can be directly replaced during the compilation period, and final variables compiled by java
1. If the following three conditions are met, a final variable is no longer a variable, but a direct amount.
Ii. Under what circumstances can the initialization value be determined during the compila
Inner (); final int I = 0; class Inner {// do not add private modifier here, otherwise the compilation error int I = 1; public void print () {System. out. println (j); modifier; otherwise, the System is incorrectly compiled. out. println (I); // at this time, the I of the local internal class is output. variables in t
the time of program initialization, so it is allocated only once, So it is shared;The static member of the class must be initialized, the same is true, because it is allocated at the time of initialization of the program, so there must be initialization, the class is only declared, in the CPP is the initialization, you can put a breakpoint on the initialization code, before the program executes the first s
method. There are two possible scenarios: 1. Repeated definition; 2. Competition will occur even if no repeated definition is generated, resulting in a deadlock problem, so that the object cannot be created. Obviously, the compiler cannot do this. A reasonable solution is to define it outside the class and share it with all objects.
Note: static constant members of a class can be initialized in the
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 form of an interface to an object or class outside.(2) for the protected modifier, its main function is to protect t
We often use four modifiers to modify variables, methods, and classes, but are the four scopes the same? Private and public may be the most known, but protected and default may not know what scope their specific scopes are. The four types of explanation are then proved by the case:Public : Has the maximum access rights. can be called by any class under the same p
, and cannot use the private variable;(2), if it is a cross-package inheritance:For the public variable in the parent class, the subclass can be inherited and can be used;For the protected variable in the parent class, the subclass can be inherited and can be used, but not subclasses are not available;For the default variable in the parent
(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 protected modifier, its main function is to protect the subclass. It means that the subclass can be decorated with its members, others cannot, it is equivalent to a su
reference:http://www.studytonight.com/java/modifier-in-java.phpModifiers is keywords that is added to the change meaning of a definition. In Java, Modfiers is cateogrized into and types:1. Access Control modifier2. Non Access modifier1) Access control modifierJava language have four access modifier to control access levels for classes, variable methods and constructor.
Default: Default have scope o
Inner class:1, the inner class defined in a class, the instantiation of the inner class is constructed with the method defined by the perimeter class, the inner class object has an implicit reference to the perimeter
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 protected modifier, its primary function is to protect the subclass. It means that the subclass can be decorated with its members, others cannot, it is equivalent to a
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.