I am trying to use reflection to return an int based on a String that's automatically generated:
try {
ItemWeight myObject = new ItemWeight();
Method method = ItemWeight.class.getMethod(easyItem.replace(" ", ""));
weight = (Integer) method.invoke(myObject);
} catch (Exception e) {
e.printStackTrace();
}
However, if the String begins with the number it is throwing an error:
public int 0PtsAllowed()
{
return 14;
}
This returns the following when compiling: Syntax error on token "0", delete this token
Any help would be greatly appreciated.
Thanks, Josh