有没有办法从 .java 文件生成 Scala 代码
可能的重复:
自动化 Java 到 Scala 源代码转换?
因为 Scala 语言拥有所有根据Java的特性,理论上应该可以从java源代码文件翻译生成Scala代码。有没有什么工具可以做这个翻译?
例如,以下 Java 代码:
public class MyClass {
String hello;
public MyClass(String hello){
this.hello = hello;
}
public void doSomething() {
Sysout.println(hello);
}
}
可以自动翻译为:
class MyClass(hello: String) {
def doSomething() {
println(hello);
}
}
Possible Duplicate:
Automated Java to Scala source code conversion?
Since the Scala language has all features of Java, theoretically it should be possible to generate a Scala code translated from java source code files. Is there any tool to do that translation?
For example, the following code in Java:
public class MyClass {
String hello;
public MyClass(String hello){
this.hello = hello;
}
public void doSomething() {
Sysout.println(hello);
}
}
could be translated automatically to:
class MyClass(hello: String) {
def doSomething() {
println(hello);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我投票决定关闭,但对于搜索引擎来说值得注意的是,Scala 不支持 Java 的一些功能,并且不适合自动转换为 Scala。这些包括。
具有运行时可见性的Fallthrough
I've voted to close, but it's worth noting for the search engines that there are a handful of features of Java that Scala does not support and which are not amenable to automatic translation to Scala. These include.
fallthrough