ani pillai

Greenhorn
+ Follow
since Feb 22, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by ani pillai

Hi,

I had a question regarding when an object that has been created locally within a method call will be garbage collected. I know we can't force GC, but is it safe to assume that usually a locally created object is up for collection as soon as you return from the method call?
15 years ago
I got only 63 % in K&B master exam, but it says that I have failed. Isn't 59% the criteria for passing 5.0?

At this rate should I risk giving my final exam or do I prepare some more?

I am trying to analyze this question from danchisholm regarding operators:



I broke down the following piece of code
int a = 1;
a += ++a + a++; System.out.print(a);

to

a = a + (++a + a++);

Now we need to analyse the bracket contents first so I get

a = a+ (2+2); and the value of a at this point is 3

So according to me when I reach the statement

a = a+ (2+2);

I should be remembering the value of a as 3 and the operation should equate to

a = 3 + (4);

But the compiler resolves the value of

a = a+ (2+2);

to

a = 1 + (4);

Why is it so?

Got it. The explanation was perfect.

Thank you!

Hi,

I am trying to clear my concepts on ambiguity issues when the compiler tries to resolve an overloaded method and I have a question. Look at the code below, now if I have a method that passes null as an argument i.e m1(null); I would expect that the compiler will complain that it cannot resolve which method to call. But it went through without an issue and called method m1(String o). Any ideas why this happened?


You might want to go through this for a better grip on the enhanced for loop syntax

http://java.sun.com/j2se/1.5.0/docs/guide/language/foreach.html
16 years ago


I was wondering if there is a good article/tutorial online that can explain how to approach the logic to override the hashcode method.

16 years ago
I can see your point Henry...not a very strong use case but I guess there is no harm in allowing it I suppose. Thanks!
What happens to memory allocation when you create an array by passing it's size as zero.

e.g. int[] array = new int[0];

The compiler does not complain, but it seems pointless to me to allow it. How is memory allocated for such a declaration?

Why is the casting of long to float implicit. I would think that because long is 64 bits and float 32 bits, an explicit cast would be required. But that is not the case...any ideas??