[!INDEX]
- try - finally block
- same child exception in multiple blocks
- tR - fn/y and try - cH block sequence ,works fine
- nested tR-cH in try block and cH. : works fine
- tR with nested tR-cH in ch block
- tR-cH , nested tR-cH in finally block. : works fine
- tR block, code statement then cH block
- single tR with multiple cH, same parent chid-chid eX
- tR-finally-catch
1. try - finally block
package package2;
public class Main1 {
public static void main(String[] args) {
try{
}finally{
System.out.println("hello"); // print hello
}
}
}
// hello
2. same child exception in multiple blocks
package package2;
public class Main1 {
public static void main(String[] args) {
try{
}catch(ArithmeticException e){
}catch(ArithmeticException e){
}
}
}
Unreachable catch block for ArithmeticException. It is already handled by the catch block for ArithmeticExceptionJava(553648315)
3. tR - fn/y and try - cH block sequence ,works fine
package package2;
public class Main1 {
public static void main(String[] args) {
try{
}finally
{
}try
{
}catch(ArithmeticException e){
}
}
}
4. nested tR-cH in try block and cH. : works fine
package package2;
public class Main1 {
public static void main(String[] args) {
try{
try{}
catch(Exception e){}
}catch(ArithmeticException e){
}
}
}
5. tR with nested tR-cH in ch block
package package2;
public class Main1 {
public static void main(String[] args) {
try{
}catch(ArithmeticException e){
try{}
catch(Exception ea){}
}
}
}
6. 1. tR-cH , nested tR-cH in finally block. : works fine
package package2;
public class Main1 {
public static void main(String[] args) {
try{
}catch(ArithmeticException e){
}finally{
try{
}
catch(Exception ea){
}
}
}
}
7. tR block, code statement then cH block
package package2;
public class Main1 {
public static void main(String[] args) {
try{
} //Syntax error, insert "Finally" to complete BlockStatementsJava(1610612976)
System.out.println("ji"); //create error
catch(ArithmeticException e){
}finally{
try{
}
catch(Exception ea){
}
}
}
}
Syntax error on token "catch", invalid RecordHeaderNameJava(1610612971)
8. single tR with multiple cH, same parent chid-chid eX
package package2;
public class Main1 {
public static void main(String[] args) {
try{
}catch(ArithmeticException e){
}catch(IndexOutOfBoundsException e1){
}catch(NullPointerException e2){
// works fine
}
}
}
9. tR-finally-catch
package package2;
public class Main1 {
public static void main(String[] args) {
try{
}finally(){
}catch(){
// not works
}
}
}
Syntax error on tokens, RecordHeaderName expected insteadJava(1610612973)