Home>Article>Java> Example analysis of Java exception handling methods

Example analysis of Java exception handling methods

WBOY
WBOY forward
2023-05-12 12:49:06 1083browse

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete