Home > Java > javaTutorial > Things to note about Java custom exception classes

Things to note about Java custom exception classes

WBOY
Release: 2023-04-26 16:19:07
forward
1148 people have browsed it

1. Notes

(1) For a parent class method overridden by a subclass, the exception type thrown by it can only be the exception class of the overridden method. Subclass or itself

(2) Among them, it is necessary to distinguish: the difference between throw and throws

2. Instance

Customized exception class inheritance The existing exception class

provides a sequence number and several overloaded constructors

public class MyException extends Exception{
    
static final long serialVersionUID = -70348975766939L;
        
public MyException(){}
        
public MyException(String msg){
super(msg);
}
}
Copy after login

The above is the detailed content of Things to note about Java custom exception classes. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template