How to call Java methods with parameters in Clojure
Overview
Since Clojure ends up running on a Java virtual environment, it is also very possible that we can utilize some of its methods.
How to call Java methods with parameters in Clojure
We can use the dot notation followed by the method we want to use, passing the parameter. Let's see an example.
Example
(ns Project(:gen-class))(defn func [](println (.indexOf "Hello World","e")))(func)
Explanation
Line 3: We create a function, func.
Line 4: We use the indexOf method to find the index of a letter in a string, and we find the index of the letter e.
Line 5: We call our function func.