{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

MoreIntroJava - The Add2Integers Program class Add2Integers...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1 The Add2Integers Program Add2Integers This program adds two numbers. Enter n2: The total is 42. 25 class Add2Integers extends ConsoleProgram { public void run() { println("This program adds two numbers."); int n1 = readInt("Enter n1: "); int n2 = readInt("Enter n2: "); int total = n1 + n2; println("The total is " + total + "."); } } n1 n2 total 17 25 42 Enter n1: 17 Graphic courtesy of Eric Roberts The GObject Hierarchy The classes that represent graphical objects form a hierarchy, part of which looks like this: GObject GRect GOval GLine GLabel Graphic courtesy of Eric Roberts HelloProgram Sending Messages to a GLabel hello, world The following program illustrates sending a message to an object. Note that the label
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}