AP® Computer Science A glossary

Initialization

Also called: initialize

Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods

Giving a variable its first value. A variable must be initialized before it is used in an expression.

Appears in the course and exam description (CED): 1.4.A.1

A variable is initialized the first time it is assigned a value. Using a variable before it is initialized does not compile. Declaring and initializing can happen in one statement: int lives = 3;.

int bonus;
bonus = 2;   // bonus is initialized here
System.out.println(bonus);

Output:

2
Learn it properly, with a checkpoint 1.4 Assignment Statements and Input

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure