简体   繁体   中英

Overriding java method with arg of type java.util.Map[String, String] in scala class

I have an abstract class, written in Java:

abstract class AbstractJavaClass {
  abstract public Map<String, String> method(Map<String, String> params);
}

I'm trying to extend this class in scala:

class ScalaConcreteClass extends AbstractJavaClass {
  override def method(params: ...): ...
}

First I've written type (...) in scala as Map[String, String] (just didn't know what to try else :)), but it says: (Note that java.util.Map[java.lang.String,java.lang.String] does not match Map[String,String])

How should I override that methods?

See this question . I think you want to write Map[java.lang.String, java.lang.String] (or even java.util.Map[java.lang.String, java.lang.String] ) (as the compiler says, actually).

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