Object is not a value error in scala

后端 未结 4 748
礼貌的吻别
礼貌的吻别 2020-12-18 21:14

While trying to make a map in Scala, I receive the following error message: object Map is not a value

The code I\'m using is the following:

         


        
4条回答
  •  一生所求
    2020-12-18 21:53

    I got similar error on Lists. try this in scala console:

    import java.util.List object test { def a():List[String] = { val list = List[String](); null }}

    you'll get the err "Object List is not a value."

    You get it because you're hiding the built-in List type, that is because List is different from java.util.List

    What if someone wants to use util.List?

    you can use a qualified name or a rename import

    ! import java.util.{List => JList}

    import java.util.{List=>JList}

提交回复
热议问题