"Sawetara pelajaran sing luwih menarik. Oh, aku seneng ngajar!"

"Aku arep pitutur marang kowe bab carane sawetara pamblokiran nyekel bisa. Iku banget prasaja: nalika pangecualian dumadi ing blok nyoba , eksekusi pindhah menyang blok nyekel pisanan ."

"Yen jinis sing dituduhake ing kurung pemblokiran nyekel cocog karo jinis pangecualian sing dibuwang, banjur eksekusi diwiwiti ing blok kasebut. Yen ora, kita pindhah menyang blok nyekel sabanjure , ing ngendi mriksa sing padha ditindakake."

"Yen kita kehabisan pamblokiran nyekel lan pangecualian durung kejiret, bakal dibalekake maneh, lan cara saiki bakal mandheg kanthi ora normal."

"Aku weruh. Blok nyekel sing pas karo jinis pangecualian bakal dieksekusi."

"Iya, bener. Nanging, ing kasunyatan iku rada rumit. Kelas bisa marisi kelas liyane. Yen kelas Cow marisi kelas Animal, obyek Cow bisa dirujuk ora mung dening variabel Cow, nanging uga dening variabel Animal. "

"Lan?"

"Amarga kabeh pangecualian marisi Exception utawa RuntimeException (sing uga marisi Exception ), isih bisa kejiret nggunakake 'catch ( Exception e)' utawa ' catch (RuntimeException e) '."

"Lan?"

"Kita bisa nggawe rong kesimpulan. Kaping pisanan, sampeyan bisa nggunakake 'nyekel (Pengecualian e)' kanggo nyekel pangecualian apa wae. Kapindho, urutan pamblokiran nyekel penting .

"Iki sawetara conto:"

" `ArithmeticException`Sing kedadeyan sawise kita dibagi 0 bakal kejiret ing blok nyekel kapindho."

Kode
``````try
{
System.out.println("Before calling method1.");
int a = 1 / 0;
System.out.println("After calling method1. This will never be shown.");
}
catch (NullPointerException e)
{
System.out.println("Null reference. Exception has been caught.");
}
catch (ArithmeticException e)
{
System.out.println("Division by zero. Exception has been caught.");
}
catch (Exception e)
{
System.out.println("Any other errors. Exception has been caught.");
}``````

"Ing conto ing ngisor iki, bakal `ArithmeticException`kejiret ing blok nyekel pisanan, amarga kabeh pangecualian marisi Pengecualian, yaiku `Exception`kalebu kabeh pengecualian. "

Kode
``````try
{
System.out.println("Before calling method1.");
int a = 1/0;
System.out.println("After calling method1. This will never be shown.");
}
catch (Exception e)
{
System.out.println("Any other errors. Exception has been caught.");
}
catch (NullPointerException e)
{
System.out.println("Null reference. Exception has been caught.");
}
catch (ArithmeticException e)
{
System.out.println("Divided by zero. Exception has been caught.");
}``````

"Ing conto ing ngisor iki, `ArithmeticException`ora bakal kejiret. Iku bakal rethrown menyang cara nelpon."

Kode
``````try
{
System.out.println("Before calling method1.");
int a = 1/0;
System.out.println("After calling method1. This will never be shown.");
}
catch (NullPointerException e)
{
System.out.println("Null reference. Exception has been caught.");
}``````

"Sing rada ngresiki. Pengecualian iki dudu topik sing paling gampang."

"Iku mung kaya ngono. Sejatine iku salah siji sing paling prasaja ing Jawa."

"Aku ora ngerti kudu seneng utawa sedih babagan iki ... "