Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I call a java static method in clojure?

Tags:

clojure

I wish to call class on the String class. How can I access this static method?

like image 260
yazz.com Avatar asked Mar 24 '11 19:03

yazz.com


People also ask

How do you call a static method in Java?

A static method can be called directly from the class, without having to create an instance of the class. A static method can only access static variables; it cannot access instance variables. Since the static method refers to the class, the syntax to call or refer to a static method is: class name. method name.

What is the correct way to call a static method named?

Static methods have keyword "static" before the method name, belong to the class and not the instance, and can be accessed through the class name. They can call other static methods and access static attributes directly but need an instance to access class attributes and methods.

How can static methods be accessed?

In the static method, the method use compile-time or early binding. For this reason, we can access the static method without creating an instance. In a non-static method, the method use runtime or dynamic binding. So that we cannot access a non-static method without creating an instance.

How do you call a static method from another static method in Java?

Call a static Method in Another Class in Java In the case of a static method, we don't need to create an object to call the method. We can call the static method by using the class name as we did in this example to call the getName() static method.


1 Answers

You can call a static method using (ClassName/methodName arguments).

However class is not a static method, it's a java keyword and you don't need it in clojure. To get the Class object associated with the String class, just use String.

like image 95
sepp2k Avatar answered Sep 19 '22 23:09

sepp2k