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 must declare a type for each variable and be careful about mixing those types. (This is actually one of the strengths of Java because the basic data types are always the same, and the programmer does not need to worry about arcane floating point standards or word orders.)

For example, one of the most common variable types is int,

Get Inside 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.