Skip to content

what is “def” in Java class

Currently, I am using RestAssured for API automation in my project. As we know, it is a Java Project.

When I look at the code of class named “TestSpecificationImpl” in Rest-Assured API. I can see that, it is using methods like:

def Response put(URL url) {
    put(notNull(url, "URL").toString())

  def Response delete(URL url) {
    delete(notNull(url, "URL").toString())

I heard about the concept of local variable type inference in java. But it is a concept of Java 10 and I am using java 8.

while googling, I find that “def” is used in python and groovy language. But, I am using java.

So, how come it is possible to use keywords like “def” in java class? Is it possible to use other programming languages keywords in java?

Please let me know in comment section, if you need any information from my end. Any help would be appreciated.

Screenshot of methods with “def” keyword:


You can find the complete code of java class at below URL:




The file you referenced is a .groovy file. You appear to have a file from the groovy RestAssured API. Try checking the version you downloaded from the RestAssured website 🙂

User contributions licensed under: CC BY-SA
1 People found this is helpful