Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting int to null

 
Martin Petransky
Greenhorn
Posts: 15
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I just came across an interesting (at least for me) one that i would like to share.


This obviously won't compile:

But this will, as the null will be boxed to Integer, and you will get.. Of course, NumberFormatException at runtime.


 
Kaydell Leavitt
Ranch Hand
Posts: 689
Eclipse IDE Firefox Browser Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, that's amazing. It must be auto-boxing the result, but I would have sworn it wouldn't have compiled!

(I got a NullPointerException though.)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic