Byte is a variable type to store 8 bit values in the

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: variables of type short because memory is rather abundant in modern computers. byte is a variable type to store 8-bit values in the range -128 ... 127. A variable of type byte occupies a single byte of memory. Variables of type char are 2-byte (16-bit) variables that are used to store 16-bit Unicode character codes. The first 256 Unicodes are the same as the codes in the ASCII coding system. char variables are like integer variables because the used character codes are integer values. However, it is better not to use char variables in situations where integer variables are needed. The integer types int, short, long, etc. will be used when we need to store whole numbers in our computer programs. The most common integer type is int. Integer variables are convenient when we want to count something in our programs. Table 5-1 summarizes the integer types and other variable types in Java. Figure 5-2 shows how some variables look like in the main memory of a computer. The other variable types will be discussed later in this chapter. T...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online