简体   繁体   中英

In Scala, how to override a method that takes a java.util.Map

The Java class I am trying to subclass has a method like:

public abstract void foo(Map var1);

I can't figure out how to override that method. The Java class I am subclassing from does not use generics.

In Scala I tried:

override def foo(var1:java.util.Map[Int,Int]){ }

But the compiler gives me the error message that it overrides nothing..

The heart of the problem is that Scala expects type parameters on the Map, however the Java class doesn't use them.

这将使它成功

override def foo(var1:java.util.Map[_,_]){ }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM