Allow to lunch instance main methods. Such methods are not static, need not be public, and need not have a String[] parameter.
class HelloWorldUsingInstanceMethod {
String greeting = "Hello, World!";
void main() {
System.out.println(String.format(":%s\n:%s\n:%s", getClass().getName(), greeting,
"Subscribe us on youtube.com/@semusings"));
}
}
java --source 22 --enable-preview HelloWorldUsingInstanceMethod.java
Unnamed classes to make the class declaration implicit
String greeting = "Hello, World!";
void main() {
System.out.println(String.format(":%s\n:%s\n:%s", getClass().getName(), greeting,
"Subscribe us on youtube.com/@semusings"));
}
java --source 22 --enable-preview HelloWorldUsingUnnamedClass.java
Please feel free to reach out to me if you have any question.
Subscribe us on YouTube https://youtube.com/@semusings