Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*จงทดสอบโปรแกรมต่อไปนี้
- 1.ถ้าหาก เพิ่ม System.out.println("hi"); ไปหลัง throw new Exception(); จะเกิดอะไรขึ้น
- 2.หากลบ throws Exception จะเกิดอะไรขึ้น
- 3. แก้ไขโปรแกรมให้ดัก exception โดยห้ามใช้ try catch ใน main */
- public class sss {
- static void f() throws Exception
- {
- if(true)
- throw new Exception();
- }
- static void g() throws Exception
- {
- f();
- }
- public static void main(String[] args) {
- try
- {
- g();
- }
- catch(Exception e)
- {
- System.out.println(">>"+e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment