Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Type of class with Class.newInstance() ?




On Apr 13, 2005, at 06:44, Joachim Haagen Bøe wrote:

But what I want to do is to be able to figure out the type of newObject, cast it to that type and edit it before it is used.

You cannot cast random objects dynamically.

But if you know the object class, you can cast it directly:

String  aClassName = "java.lang.String";
Class   aClass = Class.forName( aClassName );
Object  anObject = aClass.newInstance();
String  aString = (String) anObject;

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Type of class with Class.newInstance() ? (From: Joachim Haagen Bøe <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.