import java.util.* ;
class Ideone {
public static List< Integer> wtf( ) {
List< Integer> forty_two = new ArrayList< Integer> ( ) ;
forty_two.add ( 42 ) ;
try {
System .
out .
println ( "trying to return: " + forty_two
) ; return forty_two;
}
System .
out .
println ( e.
toString ( ) ) ; }
finally {
forty_two.clear ( ) ;
System .
out .
println ( "actually returning: " + forty_two
) ; return forty_two;
}
}
public static List< Integer> wtfff( ) {
List< Integer> forty_two = new ArrayList< Integer> ( ) ;
forty_two.add ( 42 ) ;
List< Integer> twenty_three = new ArrayList< Integer> ( ) ;
twenty_three.add ( 23 ) ;
try {
System .
out .
println ( "trying to return: " + forty_two
) ; return forty_two;
}
System .
out .
println ( e.
toString ( ) ) ; }
finally {
System .
out .
println ( "actually returning: " + twenty_three
) ; return twenty_three;
}
}
public static void main
( String [ ] args
) { System .
out .
println ( "'finally' can modify a variable being returned inside a 'try' block:" ) ; wtf( ) ;
System .
out .
println ( "'finally' can also change which variable is actually returned:" ) ; wtfff( ) ;
}
}
aW1wb3J0IGphdmEudXRpbC4qOwoKY2xhc3MgSWRlb25lIHsKCXB1YmxpYyBzdGF0aWMgTGlzdDxJbnRlZ2VyPiB3dGYoKSB7CgkJTGlzdDxJbnRlZ2VyPiBmb3J0eV90d28gPSBuZXcgQXJyYXlMaXN0PEludGVnZXI+KCk7CgkJZm9ydHlfdHdvLmFkZCg0Mik7CiAKCQl0cnkgewoJCQlTeXN0ZW0ub3V0LnByaW50bG4oInRyeWluZyB0byByZXR1cm46ICIgKyBmb3J0eV90d28pOwoJCQlyZXR1cm4gZm9ydHlfdHdvOwoJCX0KCQljYXRjaChFeGNlcHRpb24gZSkgewoJCQlTeXN0ZW0ub3V0LnByaW50bG4oZS50b1N0cmluZygpKTsKCQl9CgkJZmluYWxseSB7CgkJCWZvcnR5X3R3by5jbGVhcigpOwoJCQkKCQkJU3lzdGVtLm91dC5wcmludGxuKCJhY3R1YWxseSByZXR1cm5pbmc6ICIgKyBmb3J0eV90d28pOwoJCQlyZXR1cm4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