Originally posted by Steven Young:
Option 4 is the only one that adds an Object. All other options are adding a primitive integer. Collections can only have objects, so primitives need to be wrapped in an object,
Originally posted by Chandra Bhatt:
Suppose,if exception is thrown, you want to make return statement,
and no other statement execution of the method to proceed. But finally
will execute for sure unless you write System.exit(1) or something that
terminates the program. Suppose you dont write "return -1;" in your catch
clause, even after exception comes, a line that may outside of the try catch
clause will execute and may yield undesirable result. So you wrote "return -1" there.
Originally posted by Sourin K. Sen:
Just think about it. What's the purpose of a static import ? To import the static members of a particular class.
When you write you are telling the compiler that you want to import all the static members of Integer class so that you can call them directly without having to write "Integer." infront of them.
But when you try to write you are actually telling the compiler to import a static top level class & if you remember, top level classes can never be static which means that you cannot ever import a top level class which is static. But by writing the preceding you are trying to do just that & hence the compiler wont allow you to do so.