从 java 访问 scala 对象字段
我在从java访问scala对象的字段时遇到问题。
Scala:
object TestObject {
val field = 5
}
爪哇岛:
public class JavaTest
{
public static void main(String[] args)
{
int i = TestObject.field;
}
}
错误:
[error] JavaTest.java: cannot find symbol
[error] symbol : variable field
[error] location: class TestObject
[error] int i = TestObject.field;