How to print a string in Java?

To print a string in Java, call the System.out.println method.

For example, this is how you can print Hello World! string:

System.out.println("Hello World!");