Finish the fifth day of it 18 Palm Java Foundation Course today:
Learning content:
1,JVM Stack Space Settings
Heap Space settings: java-xmx<size>
Java-xms<size>
Stack space settings:java-xss<size>
The dead loop will not cause the stack to overflow, because in the constant pressure stack, the stack
The continuous iteration of the method causes the stack to overflow, constantly in the stack (method frame)
2, inheritance
constructor function:
Why there is no return value.
Because the constructor is fixed to return the object, it is not necessary to define the return value type.
code block
-----------------------
Building code Blocks
|-----called before the constructor function
1, local code block
Defined inside the function, in the format {}
You cannot use the static modifier,//Because static code blocks are loaded with the load of the class, and there is no way to initialize inside the function.
2, building blocks of code
|---is also a member of a class, and a member variable, member function sibling.
When constructing an object, the construction code block is called first and then the constructor.
Construct code block +static modifier----> Static code block
A static block of code executes when the class is loaded and executes only once
Static code block
----------------------------
When do you use static?
1, no data involved in object manipulation
2, all objects are manipulated by shared data.
Manual control class loading uses Class.forName ("ClassName"), which executes the code block when the class is loaded by default.
Class.forName (String,boolean Initialize,classloader) can control whether the initialization occurs when loading.
Inheritance (UP)
-----------------------------------
1, extract the common content
2, very good for reuse
3, extends
Class B extends A {...}
4,java only supports single inheritance and does not support multiple inheritance
5, Java supports multilayer inheritance (inheritance system)
|---class A
|---class B extends A
|---class C extends B
6,super keywords: Super class, Parent class
7, private properties of the parent class cannot be inherited by the quilt class, nor can private methods be overridden by the quilt class.
Specification of JavaBean
------------------
A private property,
The public getter/setter.
function override (Override)
-------------------------------------------------
Special note: When a subclass overrides a method of a parent class, the permission is a magnified or unchanging procedure and does not allow permission to be lowered
For example, the parent class method is public, the subclass overrides the method permission is private, in short, the subclass method permission must not be less than the parent class method permission.
Final
--------------------
1. Modify the class to indicate that the class cannot be inherited.
2. The modification method, which indicates that the method cannot be overridden.
Private methods can be added to final, meaningless, and compiled through. (Impossible to happen)
3. Modifier variables, can only be assigned once. If you do not assign a value, the compilation does not pass.
3, abstract class is modified by the abstract, the generality of many subclasses is extracted, but there is no definite function body.
1, abstract classes cannot be created directly from an instance,
2, the abstract method has no functional body, must be in the abstract class, why?
(to disprove, if the abstract method is in a non-abstract class, then it can be called by the object, and the method has no functional body, so it must be defined in the abstract class)
3, abstract classes can have no abstract methods, and abstract classes of non-abstract methods can call the abstract methods in this class, why?
(because abstract classes cannot be instantiated directly, so non-abstract methods are not invoked by this class of instances, and abstract methods are naturally not called, so they conform to abstract rules)
4, non-abstract subclasses of an abstract class must implement (override) all abstract methods in the abstract class, because non-abstract subclass instances require concrete implementations of methods inherited from the parent class.
Abstract subclasses of abstract classes can not implement all the abstract methods in the abstract class.
5, a non-abstract subclass of an abstract class when an object is created, the constructor of the parent class is called first (the empty argument construct is called by default) and then its own constructor is called.
Equivalent to Super (), or you can explicitly call the parent class constructor with parameters, super (Args1,args2,....)
6, abstract + static non-normal modifier combination, abstraction is in order to not let the creation of object invocation, sealing the entrance, add static, you can pass the class name. Call, Contradiction
Abstract + final non-normal modifier combination abstraction method must be overridden in a non-abstract subclass (concrete implementation), and final cannot be rewritten, contradictory
Abstract + private non-normal modifier The combination abstraction method must be overridden in a non-abstract subclass (specifically implemented), plus private, which does not have access to the non-abstract subclass of the abstract class.
4, the interface for interface programming purposes, reduce the coupling degree.
Interface
Characteristics:
1, interface is the rule of external exposure.
2, interface is the function extension of the program
3, the appearance of the interface reduces coupling
4, the interface can be used to implement multiple
5, classes can implement multiple interfaces when inheriting other classes
6, there can be an inheritance relationship between interfaces
Problems encountered:
1, constructor, construct code block, the execution order of static code block, why
Static block of code executes as the class is loaded, initializes the class, executes the construction code block, and then executes the constructor when the object is created
General execution construct code block initialize object Common Properties, constructors, initialize object-specific properties
2,super and this role as well as usage and precautions?
See Assignments
3, White rich US interface case
Questions that need help
Mating case.
This article from "Rookie Achievement Data Road" blog, reproduced please contact the author!
It 18 palm Palm Fifth day course summary