• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Boolean.TYPE????

 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the difference between Boolean.TYPE and Boolean.class??? Since
System.out.println(Boolean.TYPE==Boolean.class);
prints false.
from api documentation:
"The Class object representing the primitive type boolean. "

did not understand... Could someone clarify???
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Boolean.class is a reference to the instance of Class that represents the class Boolean.
Boolean.TYPE is a reference to the instance of Class that represents the primitive type boolean.
It is useful when using reflection.
For instance, to be able to specify which constructor do you want:

Notice that getDeclaredConstructor's argument is of type Class[]. Without Boolean.TYPE we were not able to specify the constructor taking a boolean.
By the way boolean.class references the same object as Boolean.TYPE
Reflection is not on the exam.
[ April 04, 2003: Message edited by: Jose Botella ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic