Creating Variables in Java

We've seen that Java applications are class based, and we've gotten enough Java down now to create basic programs. The next step in Java programming is to start storing your data so that you can work on that data. As with JavaScript, variables serve as locations in memory in which you can store your data. However, unlike JavaScript, Java variables are strongly typed, which means that you have to declare a type for each variable and be careful about mixing those types.

For example, one of the most common variable types is int, which stands for “integer.” This type sets aside 4 bytes of memory, which means that you can store values between -2,147,483,648 and 2,147,483,647 in int variables. Quite a few different variable ...

Get Real World XML 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.