Java Lecture5 OVR
Transcript of Java Lecture5 OVR
-
7/28/2019 Java Lecture5 OVR
1/6
1
Java 2
. .
Error (),
Out of memory, Stack overflow
Exception (),
File not found
Runtime Exception ( ), (bug)
Array out of bounds, division by zero ...
-
7/28/2019 Java Lecture5 OVR
2/6
2
. .
Throwable Java
. .
Throwable
. .
-
7/28/2019 Java Lecture5 OVR
3/6
3
. .
(throw) :
try {} catch (ExceptionClassName1 e1);
e1 ExceptionClassName1
. .
catch try, catch
catch
try {
} catch (ExceptionClassName1 e1) {ExceptionClassName1} catch (ExceptionClassName2 e2) {ExceptionClassName2}
-
7/28/2019 Java Lecture5 OVR
4/6
4
. .
finally
try {
} catch (ExceptionClassName1 e1) {ExceptionClassName1} catch (ExceptionClassName2 e2) {
ExceptionClassName2} finally {}
. .
throwable
try {} catch (ExceptionClassName1 e1) {
// :System.out.println(e1.toString());
// :System.out.println(e1.getMessage());}
-
7/28/2019 Java Lecture5 OVR
5/6
5
. .
throw
throw new IOException( );
NotInServiceException() nis =new NotInServiceException( );
throw nis;
. .
.. public boolean myMethod(int x) throws
Exception1, Exception2 { }
-
7/28/2019 Java Lecture5 OVR
6/6
6
. .
,