14
我無法從java訪問scala對象的字段。從java訪問scala對象字段
斯卡拉:
object TestObject {
val field = 5
}
的Java:
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;
要查看所有公共成員使用:'的javap -classpath'。例如。 'javap -classpath target/scala-2.9.1.final/classes TestObject' –
dsg