开发者

Except classes and interfaces is there anything else we can write in a java source file?

开发者 https://www.devze.com 2022-12-16 14:06 出处:网络
Except classes and interfaces is there anything else we can write in a java source file? because what ever .java file i have see开发者_如何学Gon will have either class or interface in it.You can also

Except classes and interfaces is there anything else we can write in a java source file? because what ever .java file i have see开发者_如何学Gon will have either class or interface in it.


You can also define enums


Aside from classes, interfaces, and enums, one can write a package-info.java which contains the Javadoc comments and annotations for a package.

There is some information regarding package-info.java in Section 7.4.1.1: Package Annotations in The Java Language Specification, Third Edition.

The use of package-info.java for package documentation is supported from the Javadoc tool which was shipped in Java 5. The What's New in Javadoc 5.0 page has an entry on the support for package javadocs.

Edit: Added information regarding support for annotations per Tom Hawtin - tackline's comment.


Nothing!

According to the JLS a completely blank file is a valid .java file. If you create an empty .java file and compile it, it compiles without error, but doesn't produce a .class file.


Yes, you can also write comments.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号