File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes issue with obtaining class name from Object passed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "issue with obtaining class name from Object passed" Watch "issue with obtaining class name from Object passed" New topic
Author

issue with obtaining class name from Object passed

El Durango
Greenhorn

Joined: Oct 09, 2003
Posts: 23
I have a simple program that demonstrates the usage of interfaces and I have an issue with obtaining a classname from an object passed to the class constructor.
Here is some code to clarify this:

and here is the class that calls this class:

I do not understand why the segment within the FactoryClass constructor gives error.
If anyone can I would appreciate it alot.
regards,
Durango
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34


The stack trace is a NullPointerException, right? Look at the above two lines: you're passing "null" as the argument to the FactoryClass constructor. The FactoryClass constructor calls a method on the passed-in argument, which gives the NullPointerException. You can't call a method on the null reference.
OK?


[Jess in Action][AskingGoodQuestions]
El Durango
Greenhorn

Joined: Oct 09, 2003
Posts: 23
*Doh!!!*
thanks dude!
 
jQuery in Action, 2nd edition
 
subject: issue with obtaining class name from Object passed
 
Similar Threads
How to Load Serialized Plugins?
Java Generics Warning
[newbie] IllegalAccessException
Exception in thread "main"
Loading POJO object without loading library first