• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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 ]
 
The moustache of a titan! The ad of a flea:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic