Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why(boolean b3=true;)(Boolean b4=true;)is both right?

 
Jianfeng Qian
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shoud'nt be
Boolean=new Boolean(true);
or
Boolean=new Boolean("true");
 
Henry Wong
author
Marshal
Pie
Posts: 21510
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Liang Anmian
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jianfeng Qian
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you .
Yes,I am using 1.5.
I will install 1.4 tomorrow
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic