• 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

Array Conversions

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a question from DanChisholm's single topic exams. Can someone tell me why the line number 5 does not throw a NullPointerException?
We know that c is null and are trying to cast a null into an array of integers. How can that be?

Thanks,
Saket
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Saket Barve:
Here is a question from DanChisholm's single topic exams. Can someone tell me why the line number 5 does not throw a NullPointerException?
We know that c is null and are trying to cast a null into an array of integers. How can that be?

Thanks,
Saket


Null pointer exeption is only thrown when you try to access a member variable or call a method on a null object.
Java allows you to cast a null object to any type, although it's still a null after casting.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic