Handling exceptions, common classes, reflection, class loading and garbage collection, Java collections framework

Source: Internet
Author: User
Tags dateformat map class

Exception Handling Overview

Check for exceptions: Checking for exceptions is usually a user error or a problem that cannot be foreseen by the programmer. (cheched)

Run-time exception: a run-time exception is a type of exception that can be avoided by a programmer during the course of a program's operation. (unchecked) Rentimeexeption

Error: In fact, the error is not an exception at all, but it is an issue beyond the control of the user or programmer.

Exceptions are problems that occur during the execution of a program. The JVM has a memory overflow, etc...

Exception handling: There are three methods of method ()

1 catch this exception and not let him continue to throw down the call stack

2 catch this exception and continue to throw down

3 thus causing the method () methods to be ejected from the call stack, the exception object continues to be thrown to the call stack under the main () method

Thowable class

A run-time exception that occurs at run time throws an err: Display

ArithmeticException Arithmetic Exception handling

System.err.println (+getmessage ());

Try: An exception code block that may occur

Catch: A code that captures such exceptions and processes

The TRY statement block does not have an exception and the catch statement block is not printed

Exceptin: Checking for exceptions

RuntimeException: Run-time exception

Error: Fault is not an exception at all

Throw: Throws an exception, throws an exception manually

Terows: Declaring an exception, throwing

The Finaly keyword is used to create a block of code right in the try block, and finaly always executes, regardless of whether the exception occurs

Catch Exception class catches a special exception before catching a generic exception

When the TRY statement block is an exception, it is not executed and jumps directly to the catch execution

Return: End Method execution

try{
Code that is protected
}finaly{
Finaly blocks are always executed.
}
User-defined Classes

All exceptions must be subclasses of Throwable

Exception exception class occurred while checking

Run-time exception continuation following RuntimeException class

Common classes


The System class represents the running platform of the current Java program

Runtime class

String class: String constant

The string class contains a immutable string

Date-related classes, dates class

DateFormat abstract class and SimpleDateFormat class

Java.text.DateFormat is an abstract class of formatted strings


Regular expressions
Matcher class and pattern class for working with regular expressions

Java Collection Framework

Set set: no order. Element cannot be duplicated

List: In order, can be repeated

Map map

Add Add remove Delete get read set correction
Sort: Ascending sort reverse: reverse sort awap Swap variable

The iterator interface is an interface for iterating through a collection

Haseset: No sorting, fast speed

List interface: elements are sequential, allowing for duplicate support for null elements

Shuffle (List): Scrambled order random

Next (); Get method, Element


Generic type

Type guarantees security of types in collections

Size Gets the collection length

Hash Map Class

map< type, type > map = new HashMap < type, type >cl;

Reflection, class loading and garbage collection


Connections: Verifying readiness Resolution

Initialization

Reflection: Runtime exploration using compiled unknown class

Compile-time type and run-time type

Dynamic check when the program is running

Loading: Class.forName (file name location)

New (Date)

... Variable parameter class object

Handling exceptions, common classes, reflection, class loading and garbage collection, Java collections framework

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.