I didn't understand the difference between these codes. One of them is compiled, the other one isn't.
{
if (true) {
try {
throw new IOException();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
This is a instance initializer, i throw a checked exception and then handle it, and this code compile.
But this one isn't compile.
{
while (true) {
try {
throw new IOException();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Exception says: Initializer must be able to complete normally
Here is the image of both Instance Initializer