• Post Reply Bookmark Topic Watch Topic
  • New Topic

in java 6 , can you upcast/downcast primitive type to objects using wrapper Classes ?  RSS feed

 
Kaylee Sebi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I know java doesn't support it under 1.4.2. In java 6 , can you upcast/downcast primitive type to objects using wrapper Classes ? Does Java 6 support the following cast ?

Long example = (Long)23L;

thanks all
 
Spencer Uresk
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I don't understand your question, but that is valid in Java 5 already. It is also unnecessary - ie,

Long example = 32L;

Will work just fine due to the automatic boxing/unboxing added in Java 5.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a quick introduction see here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!