What you are actually looking for is reflection - see Invoking a static method using reflection
in you case that would be:
Method method = tokenType.getMethod("displayString");
method.invoke(null);
A Class-object is a sort of an index. It contains methods that allow you to query what the actual .class file contains (like its methods, fields, annotations et al).
You cannot access them directly (like an index points only to WHERE the information is - not the information itself) - instead you need to query the index with i.e. Class.getMethod("nameofMethod")
once you got the "pointer" to the method you can try to call it (via Method.invoke).
Depending on what kind of method it is, you need to pass the invoke method only null (for static methods) or an instance of the object (for non-static).
Reflection allows you to create such an instance on-the-fly as well.
For more information I suggest reading up on reflection and especially the javadoc of Class. It explains a lot.
Edit: this only works if the method displayString is declared like this:
public class Bishop{
public static void displayString() {
System.out.println("Bishop");
}
}
public class Test {
public static void main(String args[]) throws Exception {
Class<?> tokenType = Bishop.class;
Method method = tokenType.getMethod("displayString");
method.invoke(null);
}
}
if there are parameter or it is private, then this will not work