Home > Java > javaTutorial > body text

Example analysis of Java exception handling methods

WBOY
Release: 2023-05-12 12:49:06
forward
1188 people have browsed it

There are 3 types throw throws The system automatically throws exceptions

throw: declare object

throws: acts on the method

public static void main(String [] args )

{

String s = "abc";

if(s.equals("abc"))

{

throw new NumberFormatException();

}

else

{

// Output

}

int div(int a, int b)throws Exception

{

return a / b;

}

}

Java What collection classes are there?

Collections in Java are mainly divided into four categories:

1. List: ordered, repeatable;

2. Queue: Ordered, repeatable;

3. Set: non-repeatable;

4. Map: unordered, with unique keys and non-unique values.

The above is the detailed content of Example analysis of Java exception handling methods. 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