What is const (constant)?

Const (constant) in programming is a keyword that defines a variable or pointer as unchangeable.

A const may be applied in an object declaration to indicate that the object, unlike a standard variable, does not change. Such fixed values for objects are often termed literals. In some languages (the C family, for example) const is part of the type while in many others it is part of the object.

Variables and constants

Types of constants include integer literals, floating point literals, character constants and string literals. While constants are often unwritable as predefined data in C, const generally does not make the value as stored in RAM unwritable. As such, const defines more how a programmer should code rather than how they can code.

In Java, const is a reserved keyword but not used.

This was last updated in October 2021

Continue Reading About const

Dig Deeper on Software development best practices and processes

App Architecture
Software Quality
Cloud Computing