Interacting with the User

There are a few different ways to interact with the user from within an application. For desktop software, you use classes in the Swing packages javax.swing. There are servlets and JavaServer Pages that allow you to interact from a Web server. However, there are many occasions on which you just want something simpler. It can be difficult to set up Swing applications with sophisticated layouts, events, and handlers. There are many times too when a console application is not only fine, but is the best choice for interacting with the user. In these cases, you turn to the System class.

Reading User Input from the Console with System.in

When you want to print something out to the console, you use the print() or println() ...

Get Java Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.