• 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
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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 ]
 
What's wrong? Where are you going? Stop! Read this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic