anonymous class implements interface; can not have arguments

0

I'm trying spark on maven but I get this problem I want to show me the port but the runable shows me this error

  

"anonymous class implements interface; can not have arguments"

Code

public class HelloWorldSparkStyle {
public static void main(String[] args) {
    Spark.get(new Route("/"){
        @Override
        public Object handle(Request rqst, Response rspns) throws Exception 
      {
            return "Hello World From Spark";
      }
    });
  }
}
    
asked by Kevin Castaño 04.06.2017 в 17:05
source

1 answer

0

The error you receive is that you are urging an object of an anonymous class based on an interface and you try to pass an argument as if it had a constructor accepting the argument.

If you want an anonymous class to receive an argument, you have to extend an abstract class that this builder provides to build it.

A interface in java does not allow builders to declare.

    
answered by 05.06.2017 в 06:06