Special exception Handling in Java--application of exception handling in user management system (very important)

Source: Internet
Author: User

How to make our exception handling flexible enough-we can create an exception class ourselves (common operations for all exceptions)

In the user management system, the specific operation is as follows:

1. Create a Userexception class

2, find superclass, click Browse, select Java.lang.Exception, complete the creation

3, open Userexception.java, you can see Userexception inheritance and exception (here you can change excetion to runtimeexception)

4, next cover the parent class construction method, right click, find souce in the Generate constructors Frome superclass

Specific examples are as follows: (Exception handling for list user management system and map user management system)

1. List User Management system

User. Java

Userexception.java

Userhandllerbylist.java

Test code and output results

2. Map User Management System

User.java

Userexception

Userhandlerbymap.java

Test code and output results

Summary: In Java, you create an exception class to handle the user management system method, relative to the C language, the code amount is greatly reduced, and the code structure is clear, it is easy to understand, in addition to modify the exception information, more convenient!

In the test, if you add multiple users at the same time, you will find that as long as a user error, no other users can continue to add, so I test with only one user to do the operation, which is also in line with the user's registration, the user is a one to register, not a pile of registration together.

Special exception Handling in Java--application of exception handling in user management system (very important)

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.