In my scala code, I'm using a java library which defines an object with a public attribute called "val":

public class XYZ {
    public int val=...
}

Is there a way to get this attribute in scala?

有帮助吗?

解决方案

You can use backticks. They remove the reserved status of any Scala keyword (or symbol).

val foo = new XYZ
foo.`val`

See the Scala Interoperability FAQ.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top