Trusted answers to developer questions

Non-primitive data types in Java

Get the Learn to Code Starter Pack

Break into tech with the logic & computer science skills you’d learn in a bootcamp or university — at a fraction of the cost. Educative's hand-on curriculum is perfect for new learners hoping to launch a career.

Java is a language that is widely used in the industry of computer science. The specialty of Java is that it provides predefined data types (i.e., primitive data types). These data types have no additional methods attached to them and are pre-defined. The other type of data that Java has is non-primitive data. This data type is provided by the programmer.

svg viewer

Non-primitive data types

There are four​ types of non-primitive data:

  • array: This is a data type used to store data in a consecutive manner. It can store any type of data as the size of the array is also declared by the programmer.

  • String: This is a data type that is used to store consecutive characters or proper sentences (e.g., String abc = "Educative is an excellent tutor";).

  • class: Classes are used to create objects. They are a very well-mannered way of merging different pieces of data into a single object.

  • interface: An interface is like a dashboard or control panel for a class. It has buttons/functions for the data types defined, but the implementation is somewhere else.

RELATED TAGS

non-primitive
data
type
java
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?