/**
* @author lautturi.com
* Java example:Check if there are arguments while executing java program
*/
import java.util.*;
import java.time.LocalDate;
public class Lautturi {
public static void main(String[] args) {
System.out.println(args.length);
if (args.length > 0) {
// there are arguments
// get the first argument
System.out.println(args[0]);
}
}
}
Running the program:
java Lautturi/hello world
output:
1 world