October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Definition of Primitive Data Type: What It Means in Java, JavaScript and Beyond

A primitive data type is a basic type a language defines itself, with its own values and operations. Java and JavaScript use the term differently, and String shows why.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A primitive data type is a basic type that a programming language defines itself, along with the values it can hold and the operations allowed on them. It is not built from other types by the programmer. The exact meaning, and the list of types that qualify, depends on the language. Java and JavaScript both use the term, but they don’t agree on every type. The clearest example is the string.

The definition, broken down

Two ideas make up the definition.

  • A type is values plus operations. Robert Sedgewick and Kevin Wayne put it this way in Algorithms: “A data type is a set of values and a set of operations on those values.” Dev.java, Oracle’s Java learning site, says much the same: “A variable’s data type determines the values it may contain, plus the operations that may be performed on it.”
  • Primitive means the language supplies it. Dev.java states: “A primitive type is predefined by the language and is named by a reserved keyword.” You don’t declare a class to get an int. The language already provides it.

This is a working definition, not a universal formal one. Each language’s documentation decides what it calls primitive.

Primitive types in Java

Java divides its types into primitive types and reference types. Dev.java lists eight primitive types in the source language:

Category Types
Integer byte, short, int, long
Floating-point float, double
Character char
Truth value boolean

A simple example is int count = 3;. The int type limits count to integer values and to the operations Java defines for integers.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Java Virtual Machine specification also defines an internal returnAddress type. It has no matching type in the Java programming language, so it isn’t one of the eight you write in source code.

Representation details are part of the language, not the term

A type’s name doesn’t fix its size or arithmetic by itself. Those details come from the language specification. In Java, int is a 32-bit signed two’s-complement integer. According to the Java SE 24 JVM specification, float and double use the 32-bit and 64-bit IEEE 754 formats. These are Java facts. Don’t assume another language’s “integer” or “number” has the same size or behavior.

Primitive doesn’t mean exact for money

Floating-point types approximate many decimal fractions. Dev.java advises against using float or double for precise values such as currency and points to BigDecimal instead.

Is String a primitive data type?

It depends on the language.

  • Java: No. String is a class. Dev.java says it “is not technically a primitive data type, but considering the special support given to it by the language, you will probably tend to think of it as such.”
  • JavaScript: Yes. MDN lists string among its primitive types.

So “always primitive” and “never primitive” are both wrong. Name the language first.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Primitive types in JavaScript

MDN defines a primitive in JavaScript as “data that is not an object and has no methods or properties.” It lists seven:

  • string
  • number
  • bigint
  • boolean
  • undefined
  • symbol
  • null

MDN also notes that primitives are immutable. You can still write something like "hello".toUpperCase(), because property access on a primitive behaves as if it were wrapped in an object (automatic boxing). The primitive itself stays a primitive. This definition is specific to JavaScript, and Java’s wording differs.

Java and JavaScript side by side

Question Java JavaScript
Is a string primitive? No, String is a class Yes, string is primitive
How many primitive types? Eight in the source language Seven
How is “primitive” characterized? Predefined by the language, named by a reserved keyword Data that is not an object and has no methods or properties
Numeric variety Several integer and floating-point types with specified formats Separate number and bigint types

Compare memory sizes only after stating the language and the implementation layer. The size facts above apply to Java.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Other languages

The same caution applies to every language. Check that language’s own documentation to see whether it uses the word “primitive” and which types it includes. This article doesn’t classify the built-in types of languages other than Java and JavaScript.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Further reading

Algorithms, 4th Edition, by Sedgewick and Wayne, covers primitive data types in Java and their values and operations. It is optional study material. The definition above doesn’t depend on it.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.