3.3. Data Types in Java

Java uses different types to store data; it is thus referred to as a strongly typed language. The range of values for these types is based on the number 2 raised to a power equal to the number of bits for each type. An 8-bit number therefore has 28 possible values, or 256 values. You may have used a bit data type in an SQL database to represent a value such as isOnSpecial where 0 means the item is not currently on special, and 1 means it is. Since 21 = 2, we see that a 1-bit number (bit) has a range of possible values of 2—it can be 0 or 1.

However, when determining the range of possible values for a data type in Java, one of the bits in the result is saved to represent the number's sign (whether it is positive or negative). ...

Get Java™ for ColdFusion® Developers 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.