• Post Reply Bookmark Topic Watch Topic
  • New Topic

Syntax is "boolean flag" but if i write "Boolean flag" so why does it works  RSS feed

 
Jigar Patel
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
syntax for boolean is
boolean flag

but then why does
Boolean flag works and dont show any error
 
Henry Wong
author
Sheriff
Posts: 23284
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"boolean" is a type (primative). And "Boolean" is a class type. Furthermore, with autoboxing, those two types are somewhat interchangeable -- although (IMHO), you really shouldn't use them that way.

Henry
 
sujith Acharya
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which version of JDK you are using? if you are using higher than 1.4 (5 or 6), implicit unboxing is done
 
Ruben Guillen
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Jigar

Boolean is a wrapper Class of primitive boolean, as mentioned by Henry, consideration on using a primitive or a wrapper class depends much on which use you will give to you variable.

For example collection classes like List, Set only access classes, they do not access primitives, then if you require that you information be stored on a List object then you should use a wrapper class.

Autoboxing, as mentioned by Sujith, is also a interesting feature to understand when using primitives and wrapper classes. Read the following article here

Regards.
 
Jigar Patel
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks All
got it
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!