Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
java-liu
alibabaStudy
Repository navigation
Code
Issues
Pull requests
9
(9)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
alibabaStudy
/
src
/
main
/
java
/
com
/
exceptions
/
Test2.java
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
35 lines (34 loc) · 1.23 KB
master
Breadcrumbs
alibabaStudy
/
src
/
main
/
java
/
com
/
exceptions
/
Test2.java
Copy path
Top
File metadata and controls
Code
Blame
35 lines (34 loc) · 1.23 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package
com
.
exceptions
;
/**
* @author Liuys
* @version V1.0
* @Package com.exceptions
* @date 2020/1/17 14:05
* 异常在继承或者实现中的使用细节
* Exception
* AException
* AAException
* BException
* BBException
* 1、子类覆盖父类方法时,如果父类的方法声明异常,子类只能抛出父类异常或者该异常的子类,或者不抛。
* 2、当父类方法声明多个异常时,子类覆盖时只能声明多个异常的子集。
* 3、当被覆盖的方法没有异常声明时,子类覆盖时无法声明异常的。
* 举例:父类存在这种情况,接口也有这种情况,
* 问题:接口中没有声明异常,而实现的子类覆盖方法时发生了异常,怎么办?
* 无法进行throws声明,只能catch的捕获,万一问题处理不了,catch中继续throw抛出,但是只能将异常转换成RuntimeException子类抛出。
* Interface Inter{
* void show();
* }
* class Demo implements Inter{
* public void show(){//不能throws Exception
* try{
* throw new Exception();
* }catch(Exception e){
* .....
* throw new RuntimeException("");
* }
* }
* }
*/
public
class
Test2
{
}
You can’t perform that action at this time.