primitive type
A basic built-in type, such as a whole number or true-or-false, whose values are held directly rather than as objects.
In more detail
Primitive values are cheap to store and copy. They usually cannot represent absence, which makes them a good choice when a value must always exist.
Examples
Java has eight: byte, short, int, long, float, double, boolean and char; collections need their wrapper classes, such as Integer.int count = 12;long total = 9000000000L;Related terms
- reference type — A type whose variables hold a reference, a pointer to an object stored elsewhere, rather than the value itself.
- wrapper class — A class, such as Integer for int, that wraps a primitive value in an object so it can be stored in collections or be null.
- int — The common integer type in many languages, holding whole numbers within a fixed range set by its size in bits.
- Boolean — A value that can only be true or false.
- char — Java's primitive type holding one UTF-16 code unit, which covers most but not all single characters.
- boxing — The automatic conversion between a primitive, such as int, and its wrapper object, such as Integer, which the compiler inserts for you.
- string — The type for text values, such as a name or an email address.
- number (type) — The type of ordinary numeric values in JavaScript, both whole numbers and decimals, stored as 64-bit floating-point numbers.
- bigint — A primitive type for whole numbers of any size, written with an n suffix such as 9007199254740993n.
- symbol — A primitive value created by Symbol() that is guaranteed unique, used as a property key that can never clash with another.
- wrapper object — An object created by new String, new Number or new Boolean that wraps a primitive value, and should not be used as a type.
Taught in
- Primitive And Reference Types — Modern Java: Virtual Threads & High-Throughput Services
- Promotion, Wrappers And The Math API — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Overloading And Varargs — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Arrays: Declare, Sort, Search, Compare — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Lambdas, Functional Interfaces And Method References — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Stream Pipelines, Primitive Streams And Optional — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: Lambdas And Streams — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Thread Safety: Locks And Atomics — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Type Annotations, Type Inference And Contextual Typing — Production TypeScript
- Verify Your Environment: Running tsc And Bun TypeScript — Production TypeScript
- Primitive Types: String, Number, Boolean, Bigint And Symbol — Production TypeScript
- Literal Types: String, Number, Boolean Literals And const — Production TypeScript
- never: The Bottom Type And Exhaustive Switch Checking — Production TypeScript
- Type Aliases Versus Interfaces: Declaration Merging — Production TypeScript
- Union Types, Intersections And Property Conflicts — Production TypeScript
- Typeof Guards, Truthiness And Equality Narrowing — Production TypeScript
- Exhaustive Narrowing With never In Production Handlers — Production TypeScript
- Generic Interfaces, Classes And Type Aliases — Production TypeScript
- Const Type Parameters: Retaining Literal Types In Functions — Production TypeScript
- Modern Decorators: Stage 3 Standards And Class Metadata — Production TypeScript
- The Spine Artifact: Generating Typed Models From OpenAPI — Production TypeScript
References
- Java Tutorials: Primitive Data Types
- Java Language Specification, chapter 4: Types, Values, and Variables
- MDN glossary: Primitive
- TypeScript Handbook: Everyday Types