How is val in scala different from const in java?
问题 Anyone care to elaborate on how val in scala is different from const in java? What are the technical differences? I believe I understand what "const" is in c++ and java. I get the feeling that "val" is somehow different and better in some sense but I just can't put my finger on it. Thanks 回答1: const in Java has no function—it's reserved but you can't actually use it for anything. Declaring a Java variable as final is roughly equivalent . Declaring a variable as a val in Scala has similar