O'Reilly logo

Java Garage by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required