Declaring Variables to Store Integers

The variable declaration statements in lines 13–15 declare that variables number1, number2 and sum hold data of type int—that is, integer values (whole numbers such as 72, –1127 and 0). These variables are not yet initialized. The range of values for an int is –2,147,483,648 to +2,147,483,647. [Note: Actual int values may not contain commas.]

Other data types include float and double, for holding real numbers (such as 3.4, 0.0 and –11.19), and char, for holding character data. Variables of type char represent individual characters, such as an uppercase letter (e.g., A), a digit (e.g., 7), a special character (e.g., * or %) or an escape sequence (e.g., the newline character, \n). The types int, float, double ...

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.