View Single Post
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 138
dickersonka dickersonka is offline Offline
Veteran Poster

Runtime classname of null object

 
0
  #1
Sep 24th, 2008
I am determining what method to call by using the runtime class. My problem is whenever I pass in a null object, obviously it will throw a null reference exception. How are you able to determine at runtime the class of a null object. Although its null i need to do further processing, and woud rather not pass in type as a parameter to the method.

Here's an example

  1. public void test(){
  2. Long nullLong = null;
  3. addParameter(nullLong);
  4. }
  5.  
  6. public void addParameter(Object value) {
  7. String parameterType = value.getClass().getName();
  8. //do some stuff here with parameterType
  9. }
Last edited by dickersonka; Sep 24th, 2008 at 1:19 pm.
Custom Application & Software Development
www.houseshark.net
Reply With Quote