head first java second edition phần 6

Nó có nghĩa là bằng tiếng Anh: "Đối với mỗi phần tử trong nameArray, chỉ định các yếu tố để narne'varlable ', và chạy cơ thể của vòng lặp."Mã khác nhau từ các phiên bản trước đó được đánh dấu màu xám. (và chúng tôi không chạy tất cả trong mainO thời gian này) | exceptions are objects I m gonna TRY this risky thing and rm gonna CATCH myself if I fall. An exception is an object. of type Exception. Which is fortunate because it would be much harder to remember if exceptions were of type Broccoli. Remember from your polymorphism chapters that an object of type Exception can be an instance of any subclass of Exception. Because an Exception is an object what you catch is an object. In the following code the catch argument is declared as type Exception and the parameter reference variable is ex. Throwable gotMeasageO prints tackTraceO Parb oi What you write in a catch block depends on the exception that was thrown. For example if a server is down you might use the catch block to try another server. Ư the file isn t there you might ask the user for help finding it. IO Exception Interrupted Exception 322 chapter 11 exception handling If it s your code that catches the exception then whose code throws it You ll spend much more of your Java coding time handling exceptions than you ll spend creatingand throwing them yourself. For now just know that when your code calls a risky method a method that declares an exception it s the risky method that throws the exception back to you the caller. In reality it might be you who wrote both classes. It really doesn t matter who writes the code. what matters is knowing which method throws the exception and which method catches it. risky method When somebody writes code that could throw an exception they must declare the exception. Aaargh tte. rtLiaST you are here 323 checked and unchecked exceptions Exceptions that are NOT subclasses of Run-bmeExCeptlon are checked for b lhe Compiler. They re called checked If you throw an exception in your code you must declare it using the throws keyword in your method declaration. wihaktd and depart Oz Walt just a minutel How come this Is the FIRST time we ve had to try catch an Exception What about the exceptions I ve .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
11    82    1    07-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.