Written by the Fiveable Content Team โข Last updated September 2025
Verified for the 2026 exam
Verified for the 2026 examโขWritten by the Fiveable Content Team โข Last updated September 2025
Definition
A global variable is a variable that is declared outside any methods or blocks. It can be accessed from anywhere in the program.
Related terms
Namespace: A namespace is an abstract container that holds variables, functions, and other identifiers. Global variables belong to the global namespace.
Modifiability: Global variables are prone to being modified from multiple parts of the program which can lead to unexpected behavior if not managed carefully.