Interop Between Java and Scala - Code Commit
9 Feb 2009 Sometimes, the simplest things are the most difficult to explain. Scala's interoperability with Java is completely unparalleled, even including languages like Groovy which tout their tight integration with the JVM's venerable standard-bearer. However, despite this fact, there is almost no documentation (aside from chapter 29 in Programming in Scala) which shows how this Scala/Java integration works and where it can be used. So while it may not be the most exciting or theoretically interesting topic, I have taken it upon myself to fill the gap. Classes are Classes The first piece of knowledge you need about Scala is that Scala classes are real JVM classes. Consider the following snippets, the first in Java: public class Person { public String getName() { return "Daniel Spiewak"; } } …and the second in Scala: class Person { def getName() = "Daniel Spiewak" } Despite the very different syntax, both of these snippets will produce almost identical bytecode when compiled.Read full article from Interop Between Java and Scala - Code Commit
No comments:
Post a Comment