Prompting the User for Input
Line 17 uses System.out.print
to display the message "Enter first integer: "
. This message is called a prompt because it directs the user to take a specific action. We use method print
here rather than println
so that the user’s input appears on the same line as the prompt. Recall from Section A.2 that identifiers starting with capital letters typically represent class names. So, System
is a class. Class System
is part of package java.lang. Class System
is not imported with an import
declaration at the beginning of the program.
Get Android™ How to Program, Second Edition 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.