Non-Primitive Data Types
Lesson 2 of 16 in Coddy's Strings and Arrays in Java course.
Non-primitive data types are called reference types because they refer to objects. In other words, they act as labels or references to more complex data structures.
The key difference between primitive and non-primitive data types is that primitive types are built-in and predefined in Java, while non-primitive types are created by the programmer and are not predefined by Java, except for the String type.
Non-primitive types can be used to call methods and perform specific actions, while primitive types cannot. Think of methods as functions that can do things with non-primitive data.
A primitive type always holds a value, whereas non-primitive types can be set to a special value called "null" to represent the absence of an object or data.
In terms of naming, primitive types start with lowercase letters, like int or boolean, while non-primitive types typically start with uppercase letters, like String, Array, Class, or Interface.
Examples of non-primitive types include Strings, which represent text, Arrays for storing lists of data, Classes for defining custom data structures, and Interfaces for specifying behavior rules for classes, among others
We will focus on String and Arrays in this course!
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
Try it yourself
This lesson doesn't include a code challenge.