Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!

Nisha Ganeriwal

+ Follow
since Feb 25, 2010
Nisha likes ...
Android Java
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nisha Ganeriwal

Any class is casted to the

more specific class that can be matched

. null is just a specific value that the class variable could have.
String and Integer classes are on the same level unlike String and Object where Object is a superclass. Thus null is casted to String in the second case preferring the subclass.
This is how the try-finally block(Exception not caught) is handled: try block is executed. If theres is an exception, it is noted(I am not very sure on how) and the control is transferred to the finally block. After successful completion of the finally block the exception is passed on.

In your code, there is an exception(ArrayStoreException) in the inner-inner finally or the inner-try, this is noted and the inner-finally executed. Now inner-finally doesn't complete successfully so exception(ArrayStoreException) is forgotten(if it is correct to use the word). Now InterruptedException which occured in the try block(or inner-finally) is noted and control transferred to the outermost finally where Arithmetic Exception occurs causing finally to end abruptly and InterruptedException being forgotten. the Arithmetic Exception which occurred in the finally-block is now passed on for handling.

Section 7.13 on the page explains how this exactly works.

To summarize, if finally ends abruptly, any exception in the try block is forgotten.

I hope that made some sense.
10 years ago
You cannot declare an array like that. Declare the array outside the loop:

You can then do the initialisation in the loop.
Also specifying the array size in the declaration is not legal and will not compile.
Refer here.
10 years ago
In the recursive methods, you can store the value returned by nCr_recursive(..) in a variable, compare it with 0 and throw the exception.
10 years ago
In the "bad" methods, when you write: answer = answer * ((n - i) / (i + 1)); , in the division, you loose precision because when you divide int by int the result is an int and the remainder is lost. But this does not happen in the "good" methods as there the answer*(n-i) is calculated first which is always perfectly divisible by (i+1).

10 years ago
I am also preparing for scjp and if i understand generics so far thn i think what they mean is that cList could be of type Dog or its subtypes and neither can b assigned an Integer list. clist can not be of type super classes of Dog.
Check the io streams you are using. You may not be writing the file properly.