Mailing Lists: Apple Mailing Lists

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

Calling class methods for annoymous class object?



Hello,

I'm writing a file parser that needs to the results of it parsing into
a particular class. In the name of good code re-use in the future I
didn't want this particular class name (AddressItem.class in this
case) to be hard coded. Instead I pass a String with the name of the
class to the constructor and do something of the following order:


String className = "AddressItem.class"; Class classObj = Class.forName(className); Method[] mList = classObj.getMethods(); //Instantiation: Object item = classObj.newInstance();



So I have new instance object and a Method ArrayList which contains
the names of the methods in the Class. But what I don't understand is
how to call a particular method using it's name?

Many Thanks,

Saad Mahamood.
_______________________________________________
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


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.