TypeCast to Object

Hi,I am working with java, in my logic i am getting values in the form of Object, here iwant to typecast it to my won class , but here i am having only the class name, so How can i typecast that Object by using this class name which is in string format. Regards
[296 byte] By [mymessagesa] at [2007-10-3 4:12:19]
# 1
You can't. What would the code look like? and how did you get into this pickle?
ejpa at 2007-7-14 22:13:01 > top of Java-index,Java Essentials,Java Programming...
# 2
And what would be the point of casting an object if you only had a String for the type name? If you didn't have an appropriately typed reference you wouldn't have any way to manipulate it (other than by reflection which doesn't require casting in the first place).
dcmintera at 2007-7-14 22:13:01 > top of Java-index,Java Essentials,Java Programming...
# 3

You can't do it in first palce . Other thing is to deal with such kind of problems like you recieve an object and you have to cast it to one amonst many of your own classes (adn you don't know which type comes when) , have an interface with all common functions defined in it and always cast your object to that Interface and call the method . By run-time polymorphism , always proper method will get called.

balaji31a at 2007-7-14 22:13:01 > top of Java-index,Java Essentials,Java Programming...
# 4
Ah, clarity itself.
dcmintera at 2007-7-14 22:13:01 > top of Java-index,Java Essentials,Java Programming...
# 5
> adn you don't know which type comes whenI may not know which type comes when but I do know that this type comes then.
oxbow_lakesa at 2007-7-14 22:13:01 > top of Java-index,Java Essentials,Java Programming...
# 6
Have your classes implement an interface (i.e. Command Pattern) then you don't care what the name of the class is.
YoGeea at 2007-7-14 22:13:01 > top of Java-index,Java Essentials,Java Programming...