可能重複:
Accessing scala object fields from java斯卡拉「對象」變量不可見從Java?
我有這樣的斯卡拉對象
object Foo {
val TOTAL = 10
def totalMethod = 10
}
當我做這在Java代碼:
System.out.println(Foo.totalMethod());
它的工作原理,但是當我做
System.out.println(Foo.TOTAL);
它並不:
[error] /Users/pfernand/Projects/foo/Whatever.java:23: cannot find symbol
[error] symbol : variable TOTAL
[error] location: class Foo
[error] System.out.println(Foo.TOTAL);
[error]
確實是重複的。對不起,但我無法通過谷歌搜索找到答案:( – 2012-08-09 16:38:38