Scala and Java in same project

后端 未结 2 1218
温柔的废话
温柔的废话 2021-02-19 23:02

Can I use Scala and Java in the same project? I am new with programming so it\'s a litte bit confusing for me.

From my research I have read that the best combination to

2条回答
  •  难免孤独
    2021-02-19 23:54

    Short answer

    Yes

    Longer answer

    Scala and Java work good together.

    Scala main compilation target can be compiled is Java bytecode that runs on any JVM. On top of runtime compatibility, the Scala language itself supports interoperability.

    So the basic project setup looks like

    ./src
       /main
           /scala
           /java
        test
            /scala
            /java
    

    How everything is bound together is determined by the build system that you are using, i.e. sbt, gradle or maven all provides good support here.

提交回复
热议问题