Intro to Java Web-Notes_Part38

Intro to Java Web-Notes_Part38 - Ty"es Home About Us...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: Ty "es Home - About Us Primitive Data Types Computers are all about storing and manipulating data. Java has eight primitive, or built-in, data types. The programmer can also create any number of customized abstract data types. Of the eight primitvie data types, the four types we'll use most frequently are: 0 int - double ° char 0 boolean the other four primitive data types are: 0 byte - short - long - float When Java is storing and manipulating a piece of data, it is very careful about keeping track of both its value and its type. If a program needs a place to keep track of a person's age, it might have a Java statement such as int age; This is a declaration statement. A declaration statement is used to create a variable of a specific type. The declaration statement does the following three things: 1. Grabs a chunk of memory. 2. Notes that that memory piece of memory can only store values of the indicated type. 3. Gives that chunk of memory a name (in addition to the address that is automatically associated with each chunk of memory). For example, the declaration statement int age; grabs four bytes of memory for the variable age, which will be used to hold only int values (Whole numbers), and can be referenced by the name age. A computer's memory is a series of data cells called bytes. Ea ch hyiwze a? mammary has an address. [Ema E5 [3315 2). A single byte of memory is only large enough to store a single character. Four bytes of memory are required to store an integer. So, the age variable declared above might take the four bytes shown below: This variable “age” arr hugger: which requires f0»er {.mtiguous bytes of memory Four bytes of memory is enough space to keep track of the integer values from approximately negative two billion to positive two billion. The table below shows information on the four primitive data types we'll focus on. Memory Used Range of Values ...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

Intro to Java Web-Notes_Part38 - Ty"es Home About Us...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online