I have a problem using the reflection in Java I am trying to save a method of a data structure I am getting an error but the error is
The method, in this case, I am trying to obtain which is the add method for serial list, which takes comparative and an object as its parameter. Thanks in advance! Added: Here is the SerialList's method sign You are saying - The law, in this case, what I am trying to achieve An add method for a serial list that is the parameter of Comparable object But passing the squares - Just a note - Only public methods are visible to java.lang.NoSuchMethodException: cs671.eval.SerialList.add (java.lang.Integer, java.lang.String) < / P>
structType = "cs671.eval.SerialList" ,
keyType = "java.lang.Integer" , and
valType = "java. Lang.String " is a string that was read from a file.
class data class = faucet, comparable class = zero, objectClass = null; Try {// Create data structure data class = class. ForName (structType); ComparableClass = Class.forName (keytype); ObjectClass = Class.forName (valType); } Catch (Klasnotfound exception e) {} java.lang.Object structObj = null; Try {// Create a data structure object structure obz = data class.Newinstance ()); } Hold (exception e) {} method m = null; Try {// attempt to add method to data structure m = dataClass.getMethod ("add", comparable class, object class); Actually I am trying to get the right classes correctly on the right classes which are the passing classes i in that method, but I do not know how those classes (comparable class and object class) are right.
Add Public Zero (java.lang.Comparable, java.lang.Object)
java.lang.Integer ,
Java. Lang.String .
getMethod () for non-publications, you must use the
G-Endclaimer Method () Instead.
No comments:
Post a Comment