This article mainly introduces exceptions and packages in the basics of java. Friends in need can refer to it
1 Exceptions
Exception system
• Throwable
Error
# Usually major problems occur, such as: the running class does not exist or memory overflows, etc.
Do not write code to handle it
Occurs at runtime In this case, you can use try catch finally
The subclass names of Exception and Error are suffixed with the parent class name.
1.1 Methods in Throwable
##1.2 throws and throw
try { 需要检测的代码; } catch(异常类 变量) { 异常处理代码; } finally { 一定会执行的代码; }
Inherit Exception or its subclasses.
constructor .
Example:
Class DemoException extends Exception { DemoException(String message) { super(message); } }
1.5 Exception details
##2 Package
Category management of class files.
Provide multiple layers of
to classes.
is written on the first line of the program file.
The full name of the class name is package name.class name.
Package is also a form of encapsulation.
The class permissions in the accessed package must be public.
Member permissions in a class: public or protected
protected is a permission provided to subclasses in other packages
Routine
##3 import
4 Jar package
4.1 Operation of Jar package
Through jar. The operation of jar by exe tool.
jar -cvf mypack.jar packa packb
jar -tvf mypack.jar [>Directed file]
jar -xvf mypack.jar
jar –cvfm mypack.jar mf.txt packa packb
Java Free Video Tutorial
2. YMP Online Manual
3. Comprehensive analysis of Java annotations
The above is the detailed content of Summary of exceptions and packages during java development. For more information, please follow other related articles on the PHP Chinese website!