在一个文件 bencode.scala 中写入 println("encode") 为啥报错了! mv bencode.scala Bencode.scala 就可以了

分享 未结
0 0 1 7
nikaxi 2019-02-14发布
收藏 点赞

bencode.scala:1: warning: Main has a main method with parameter type Array[String], but Main will not be a runnable program.

 Reason: companion contains its own main method, which means no static forwarder can be generated.


println("hello")

^

回帖
  • 2019-02-14

    Scala程序的执行入口必须是一个包含main方法的object,例如:

    object Test {
      def main(args: Array[String]) {
        println("hello")
      }
    }
    

    或者简写为:

    object Test extends App {
      println("hello")
    }
    


    2 回复