I am getting the parameter types of a method in a class as
Class[] parameterTypes=method.getPrameterTypes();
I need to test if the parameter types are of primitive types i.e int or String or long etc...If its not it should show a message box. For that i used the following code.The trouble is that it doesnt seems to test the whole conditions.It seems to check only the first condition and for all other conditions it gives a negative result.i.e for String,long,float etc it shows the message box whereas it should be executing else condition instead.Please tell me whats wrong with it.
Thank you all in advance. [ August 08, 2006: Message edited by: Bear Bibeault ]
Are you sure that Class.toString returns the result you're expecting? toString returns a string representation, but not necessarily the one you would expect. Try the getName method instead. Also, don't call it 9 times - call it once, and store the result in a variable.
It would seem much better to test the class of the arguments rather than the class name. You can then simplify the problem to checking if the class of the parameters is in an allowable set. For example -
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.