2.5.5 Prompting the User for Input
Line 17
System.out.print("Enter first integer: "); // prompt
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 2.2 that identifiers starting with capital letters typically represent class names. Class System
is part of package java.lang. Notice that class System
is not imported with an import
declaration at the beginning of the program.
Software ...
Get Java™ How To Program (Early Objects), Tenth 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.