Learn Java DAY8 from scratch

Source: Internet
Author: User

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.