Michal Burak

Greenhorn
+ Follow
since Oct 05, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Michal Burak

Adam Smolnik wrote:An unintended side effect is possible according to me - (redundant) creation of several new FooClass(barCode) instances during simultaneous initial access.

Adam



Yes. But those objects (the redundant copies) will be available for GC just after the method returns. I did not find a solution for that, any ideas?

Jelle Klap wrote:

Aside from the potentially (...)



Thanks for the info. Do you have any ideas how to solve my problem if I am determined to use a cache? I will access this method very frequently, and the pool of the objects can be 8-15 maximum.

Is there a way to implement such valueOf methods? I looked at the JDK sources and those are different case, since I have no idea what barCode can be.

EDIT2:
I am sure that I will have a maximum of about 15 objects I this cache. But the method will be called veery frequently. So I want to use it to optimalise memory usage so that I dont create lots of equal immutable objects.
Hi,

Any ideas if this can be not thread safe?


Why does this produce "true qwe"?

Thanks!


Why this does not print anything?


Why does this not compile?
As I understand x should store any element that is a super type of String (? super String)?

Thanks for help.

Ankit Garg wrote:Yes you are right, this is an error in the mock exam. This has been asked before too

And welcome to javaranch...



Thanks
K&B Exam SCJP6 quiz 1 question 52:



My code that prints "false true" is below. Hashcodes are not equal, equals returns true. But equal objects must have equal hashcodes.
So conclusion: only "C" is the correct answer ("D" is not correct opposed to what it says in the mock exam). Am I right or do I miss something?