View Single Post
Join Date: Jun 2008
Posts: 973
Reputation: Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough Alex Edwards is a jewel in the rough 
Solved Threads: 107
Alex Edwards's Avatar
Alex Edwards Alex Edwards is offline Offline
Posting Shark

Re: Runtime classname of null object

 
0
  #5
Sep 24th, 2008
Originally Posted by dickersonka View Post
I am working on a logger showing showing types and values for classes and sql statements (ie parameters in sql statements)

From the example above I will need to show output as something like
Long: null and BIGINT: null

What is a possible recommendation to be able to do this?

Should I create overloaded methods for each type or pass in the class at runtime? Any other suggestions are welcome and thanks for your help!!!
This might help--

  1. public class NullTest{
  2.  
  3. public static void main(String... args){
  4.  
  5. Object obj = null;
  6. System.out.println(determineNull(obj));
  7. obj = new Object();
  8. System.out.println(determineNull(obj));
  9. }
  10.  
  11. private static String determineNull(Object o){
  12. return (o == null) ? "Object is null": "Object is not null";
  13. }
  14. }
Reply With Quote