I wish to call class on the String class. How can I access this static method?
4 Answers
An example is worth 100 words:
(. String (valueOf 1))
1 Comment
Joel M
If I have an instance of a class but not the class name itself, how can I call a static method? (. (class my-instance) staticMethod 10). I get an error "No matching method staticMethod found taking 1 args for class java.lang.Class", even though (class my-instance) does not return java.lang.Class.
Your question has been answered, I think, but if you really do want to get the class of an unknown object, you can use the class function:
> (class "Foo")
java.lang.String
As in java, to specify classes outside of java.lang as literals, you need to either import them, or specify the full package + class name using dot (.) separators.