| Author |
why(boolean b3=true;)(Boolean b4=true;)is both right?
|
Jianfeng Qian
Ranch Hand
Joined: Jan 25, 2005
Posts: 83
|
|
shoud'nt be Boolean=new Boolean(true); or Boolean=new Boolean("true");
|
Jianfeng Qian<br />SCJP 1.4, SCBCD 5.0(beta)
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
I am assuming that you are using Java 1.5, which is why "Boolean b4 = true" works. Java 1.5 introduced an autoboxing feature which converts between primative types and their object counterparts automatically. Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Liang Anmian
Ranch Hand
Joined: Jun 25, 2004
Posts: 119
|
|
|
Hey there, when you study for the exam, and wish to try out codes, please make sure you are using the 1.4 compiler. As mentioned, Boolean something = false works because version 1.5 introduces an autoboxing feature. But in 1.4, this is a compilation error. So please pay special attention to this, else you may study the wrong thing.
|
Current Status:<br /> <br />SCJP 1.4<br />SCJD (in progress)
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
Hey there, when you study for the exam, and wish to try out codes, please make sure you are using the 1.4 compiler. Unless, of course, you're studying for the 1.5 exam. The general rule is: know what exam you're preparing for, and make sure you are using the correct JDK for that exam.
|
"I'm not back." - Bill Harding, Twister
|
 |
Jianfeng Qian
Ranch Hand
Joined: Jan 25, 2005
Posts: 83
|
|
Thank you . Yes,I am using 1.5. I will install 1.4 tomorrow
|
 |
 |
|
|
subject: why(boolean b3=true;)(Boolean b4=true;)is both right?
|
|
|