1.object subclasses of all parent classes of God Class
A super () is hidden in every class. The final parent class is all pointing to the object class
You can use this to achieve polymorphic instanceof
2. Inner class
As the name implies, a class within a class, in order to increase the simplicity of the code, so that a function can be continued to use
Class A
{
Class b{
}
}
Of course, if the outer class (A) wants to use a local variable defined in B, then it needs to be static for B and this local variable.
Want to new a B object, writing: new A.new B
Static Class B
Using methods and functions consistently
2.1
Anonymous inner class
An inner class without a name, but requires an inheritance or implementation relationship
Class A
{
Class extends c{
}
}
3 new objects can also be written like this
New A () {//a can be any name (no need to have occurred)
void Show () {};
}.show ();
4. Keyword Exception in Java error is also a class
This class is already defined, and once an error occurs, the system will determine the error and give a hint, and terminate the program
If you want to define your own hints, you can
Keyword throws throw
The difference between the two is that throws can throw the error out of the class, the function, and throw it out of the local variable.
try{
}
catch (Exception e) {
}
finally{
}
These three keywords Try,catch try,finally, catch, finally can be group together
Put the potentially wrong program into the try inside if an error occurs executing the statement inside the catch, the statement inside the finally is bound to be executed
This will ensure that the program does not abort
Learn Java DAY8 from scratch