Читать книгу OCP Oracle Certified Professional Java SE 17 Developer Study Guide - Jeanne Boyarsky - Страница 71
Single-File Source-Code
ОглавлениеIf you get tired of typing both javac
and java
every time you want to try a code example, there's a shortcut. You can instead run
java Zoo.java Bronx Zoo
There is a key difference here. When compiling first, you omitted the .java
extension when running java
. When skipping the explicit compilation step, you include this extension. This feature is called launching single-file source-code programs and is useful for testing or for small programs. The name cleverly tells you that it is designed for when your program is one file.