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;
}
}
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!