System.out.println("Hello, World!");
Scanner scanner = new Scanner(System.in); System.out.print("Please enter your name: "); String name = scanner.nextLine(); System.out.println("Hello, " + name + "!");
String javaVersion = System.getProperty("java.version"); String osName = System.getProperty("os.name"); System.out.println("Java version: " + javaVersion); System.out.println("Operating system: " + osName);This code retrieves the Java version and the operating system name and prints them to the console. In all of these examples, the System class is used from the java.util package library.