Title: Key Concept - Java Variables
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: Learning Modules

A variable in Java is:

- A named spot in memory used to hold a value.
- Declared with a name that:
  - Begins with a letter, dollar sign ($) or the underscore character (_)
  - Is optionally followed by any sequence of letters, digits, dollar signs or underscores
  - May not be a keyword or reserved word. See Oracle's list of Java Language Keywords
- Declared with a type which may be one of:
  - Primitive data type - byte, short, int, long, float, double, boolean and char
  - Java-defined class - one of the numerous classes defined in the Java Platform API (String, System, Thread, etc.)
  - User-defined class - a class defined by the developer
- Types include:
  - Instance variable - non-static field defined within and associated with one object
  - Class variable - a static field defined within and associated with a class
  - Local variable - defined within and accessible only within a method
  - Parameter - defined in the signature of a method