如果编译一个空的java文件会发生什么? [英] What happens if you compile an empty java file?

查看:138
本文介绍了如果编译一个空的java文件会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译一个空的java文件时,它没有生成任何类文件。所以想知道编译器在编译空java文件时如何反应。它应该在这里生成一个空的类文件,为什么它没有?

When i compiled an empty java file it didn't produce any class file. So wanted to know how compiler react when compiling an empty java file. It should have generated an empty class file in this, why it didn't?

推荐答案

javac 启动,看到文件中没有声明类,并完成。为了创建 .class 文件,您必须至少在文件中包含类声明。

javac starts, sees there is no class declared in the file, and finishes. In order for a .class file to be created you must at least have the class declaration in the file.

这篇关于如果编译一个空的java文件会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆