boolean are primitives, while
String is not.
This can be contrasted with c where
string is a primitive (essentially an array of
What is the term for types that aren’t primitive?
The most general term (language agnostic) is a composite data type.
In Java there are several types of composite data type, the most obvious is a Class but an Enum would be another example.
A boxed type is another related term, which is a primitive wrapped in a class to provide an object oriented interface. Examples of this in Java are an
int vs. an
Integer or a
char vs. a
In java, int, byte and boolean are primitives, while String is not.
String is actually a boxed type. Under the hood it's implemented as a char array just like C and you could use a char array too if you wanted. Obviously most people don't do this as you won't have any of the convenient abstractions provided by the
Here's how the java.lang.String class is implemented in openjdk:
/** The value is used for character storage. */ private final char value;
As you can see, there's nothing special about a string in Java.
Correct answer by thexacre on December 24, 2020
One answer to this question may be CDTs, but I don't think that is a general enough response. CDTs only account for a subset of non-primitive types: the definition of CDTs does not account for types that include methods. In fact, CDT is further misleading as they are expected to aggregate data, i.e., include fields. It is not a requirement for non-primitives to have fields.
There are ample examples of non-primitive non-UDTs, e.g., String in Java.
This doesn't help either. Consider that a pointer in C may point to anything, including primitive types.
As far as I am aware there is no general term for non-primitive types. Maybe except, as mentioned by @Doval, "non-primitive type".
Answered by David Poxon on December 24, 2020
1 Asked on January 31, 2021 by derek
5 Asked on January 28, 2021 by timmy-zhou
1 Asked on January 26, 2021 by szeb
2 Asked on January 24, 2021 by envin
4 Asked on January 21, 2021 by ran-keren
1 Asked on January 19, 2021 by inx51
1 Asked on January 18, 2021 by scttrbrn
0 Asked on January 14, 2021 by two-horses
3 Asked on January 9, 2021
3 Asked on January 9, 2021 by finlay-weber
2 Asked on January 4, 2021 by buddygyan
1 Asked on January 3, 2021 by saif-ul-islam
1 Asked on December 31, 2020 by eyad
1 Asked on December 30, 2020 by bart-robinson
2 Asked on December 28, 2020 by keezar
1 Asked on December 22, 2020 by toivo-swn
2 Asked on December 21, 2020 by timsch
Get help from others!