object: is the indirect father of all objects directly to the latter, the legendary God. What is defined in this class is definitely the functionality that all objects have.
The object class already provides a comparison method for whether the objects are the same.
If the custom class also has the same functionality, there is no need to redefine it.
Overwrite: only follow the function in the parent class, build your own unique comparison content, this is the overlay.
Access rules for internal classes:
1, the inner class can access the members of the external class directly, including the private.
Members in an external class can be accessed directly because the inner class holds a reference to an external class, the format, and the external class name. This
2, the outer class must establish an inner class object to access the inner class.
Access format:
1, when the inner class is defined on the member position of the outer class, and is not private, it can be in an external other class.
You can create an inner class object directly.
Format
The outer class name. Internal class Name Variable name = External Class object. Inner class object;
Outer.Inner in = new Outer (). New Inner ();
2, when the inner class is in the member position, it can be decorated by the member modifier.
For example, private: Encapsulates inner classes in the outer class.
Static: The inner class has static properties.
When an inner class is modified by static, only static members in the outer class can be accessed directly, and access restrictions occur.
In other external classes, how do you directly access the non-static members of the static inner class?
New Outer.Inner (). function ();
In other external classes, how do you directly access static members of static internal classes?
Uter. Inner.function ();
Attention:
When a class static member is defined in an inner class, the inner class must be static.
When a static method in an external class accesses an inner class, the inner class must also be static.
When describing things, there is something inside the thing, which is described by an inner class.
Because internal things are using the content of external things.
Class body{
Private Class xinzang{
}
public void Show () {
New Xinzang ()
}
}
Internal classes are defined at local time:
1, can not be modified by member modifiers
2, you can access members in an external class directly, because you also hold references in external classes.
However, it is not possible to access the variables in its local area, only the local variables that are final decorated.
Anonymous inner class:
1, the anonymous inner class is actually the shorthand format for the inner class.
2, the premise of defining an anonymous inner class: An inner class must inherit a class or implement an interface.
3, Anonymous inner class format: New parent class or interface () {Defines the contents of a subclass}
4, in fact, anonymous inner class is an anonymous subclass object, and this object is a bit fat. It can also be understood as an object with content.
5, it is best not to have more than 3 methods defined in an anonymous inner class.
Test.function (). method ();
Test.function (): There is a static method function in the test class.
. Method (): Function The result of this method operation is an object. And is an object of type Inter.
Because only objects of type Inter are allowed to call method methods.
(Sunny, written on July 10, Guangzhou, reproduced please indicate the source, thank you, PS a few words, the night before yesterday to send friends home, drank a lot of wine, it would have been every day in the days and nights of study, the body has been overwhelmed, eat seafood drink wine, seafood is not particularly fresh, also too spicy, the evening also use cold shower, , drink the pores of the whole body is open do not take a cold shower and be blown by the wind, evil into the body, ah, this wine has become the last straw to destroy their body, thoroughly put the body down, the next day of diarrhea all over the whole day, the entire body pain, stand up, stand up straight to 5 seconds, black, Write down this paragraph when the mouth with three pieces of red ginseng, today has slept for 10 hours, if the body has vitality words, feel ten not save nine, the waist has no strength straight up, one day only drank a bottle of milk to eat a piece of bread, advised the same in the study program comrades, must keep the body good, Really all of everything, is inseparable from a good body, she is you do all the fundamental, every day to exercise the body, run, also equivalent to relieve their pressure, every day to adjust their own state of good, to have energy and power and ability to program the world to create AH, today really no mood to review, Take a look at the new technology, relax, and finally, the previous resignation is also because of the reason for drinking every day, now start, I decided to quit drinking! Please supervise, hope that they can live, and continue to be together with you, I wish you health, academic progress, sincerely salute! )
Java Basics Review 4-6