. Net to Java.03. check exception and non-query exception,. net to java.03

Source: Internet
Author: User

. Net to Java.03. check exception and non-query exception,. net to java.03

After turning to Java, I found a very demon thing. Why is there a throws XXXXException behind some methods?

For example, the following code

    @Override    public <T> ResponseEntity<T> exchange(String url, HttpMethod method,            HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables) throws RestClientException {        RequestCallback requestCallback = httpEntityCallback(requestEntity, responseType);        ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType);        return execute(url, method, requestCallback, responseExtractor, uriVariables);    }

This is a syntax not available in. NET. An exception occurs during query.

 

This is an explanation taken from Java core technology. I feel very clear.

The Java language specification calls all exceptions derived from the Error class and RuntimeException class as unchecked exceptions [in the green section], and all other exceptions are called checked) exception [blue part in ].

The compiler checks whether an exception processor is provided for all checked exceptions.

The check exception can be either handled internally by the method, or the caller is prompted for handling through the method declaration (for example, the file cannot be found)

Non-checked exceptions are either uncontrollable (such as OOM) or avoided. In theory, they can also be completely avoided (such as the case of null reference)

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.