A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
== and != on wrappers
Joined: Aug 25, 2008
Nov 12, 2008 12:00:00
Solving some questions about wrappers I got really in doubt on how to use == and != operators.
I've read K&B 5 chapter about wrappers but the portugueese translation drove me nuts !
What do they compare ? They look if the reference instances the same object ?? Is that ??
Joined: Sep 28, 2004
Nov 12, 2008 12:24:00
If both sides are wrappers (meaning instances), then it is comparing the references. The two sides are equal if they are the same object.
If only one side is a wrapper, then autoboxing will unbox the wrapper -- and it is the values that will be compared. The two sides are equal if they represent the same value.
Java Threads, 3rd Edition
Jini in a Nutshell
Java Gems (contributor)
Don't get me started about those stupid
subject: == and != on wrappers
URLs and appending parameters
why can we write List list = new ArrayList();
query in answer
tricks to wrapper methods
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013