Data structure method organizing the data in the memory. The data have the right to be organized in two ways either linear or non-linear way.

You are watching: Difference between primitive and non primitive data types in java

There space two species of data structure obtainable for the programming purpose:

Primitive data structureNon-primitive data structure

Primitive data framework is a fundamental kind of data framework that shop the data of only one type whereas the non-primitive data structure is a form of data structure which is a user-defined that stores the data the different species in a solitary entity.

*
Primitive data structureNon-primitive data structure
Primitive data structure is a kind of data structure that shop the data of just one type.Non-primitive data framework is a type of data framework that deserve to store the data of much more than one type.
Examples of primitive data structure are integer, character, float.Examples of non-primitive data structure are Array, linked list, stack.
Primitive data structure will contain part value, i.e., it can not be NULL.Non-primitive data structure have the right to consist of a NULL value.
The size relies on the type of the data structure.In situation of non-primitive data structure, size is not fixed.
It starts with a small letter character.It starts with an uppercase character.
Primitive data structure can be offered to speak to the methods.Non-primitive data framework cannot be used to call the methods.

Primitive data structure

Primitive data framework is a data structure that deserve to hold a solitary value in a certain location whereas the non-linear data structure have the right to hold multiple worths either in a contiguous ar or arbitrarily locations

The examples of primitive data structure room float, character, integer and also pointer. The value to the primitive data framework is listed by the programmer. The complying with are the 4 primitive data structures:

Integer: The creature data kind contains the numeric values. It contains the totality numbers that have the right to be either negative or positive. Once the range of essence data kind is not huge enough climate in that case, we can use long.Float: The rise is a data kind that can hold decimal values. When the precision that decimal value increases then the dual data kind is used.Boolean: the is a data form that have the right to hold one of two people a True or a False value. That is mainly used for checking the condition.Character: the is a data form that can hold a single character value both uppercase and lowercase such together "A" or "a".

Non-primitive data structure

The non-primitive data framework is a sort of data framework that deserve to hold multiple worths either in a contiguous or random location. The non-primitive data varieties are characterized by the programmer. The non-primitive data structure is further classified into two categories, i.e., linear and non-linear data structure.

In instance of direct data structure, the data is save in a sequence, i.e., one data after another data. When we accessibility the data from the linear data structure, we just need to begin from one place and will uncover other data in a sequence.

The complying with are the types of direct data structure:

Array: selection is a data framework that have the right to hold the aspects of exact same type. It cannot contain the aspects of different types like integer with character. The generally used procedure in an array is insertion, deletion, traversing, searching.

For example:

int a<6> = 1,2,3,4,5,6;

The above example is variety that has the integer type elements stored in a contiguous manner.

String: cable is defined as an array of characters. The difference in between the character array and also string is the the string data framework terminates with a "NULL" character, and also it is denoted together a "\0".

String data structure:


In the above example, the length of the string is 17 as the last character is the NULL character which denotes the discontinuation of the string.

Char Representation:


In the over example, the size of the string is 16 as it does no have any type of NULL character together the last character to signify the termination.

Stack: ridge is a data framework that adheres to the principle LIFO (Last In an initial Out). Every the operations on the stack space performed from the optimal of the stack such together PUSH and POP operation. The push operation is the process of inserting element into the stack while the pop procedure is the procedure of removing aspect from the stack. The ridge data structure deserve to be enforced by utilizing either selection or attached list.

See more: How Many Protons Are In Te Llurium, Tellurium, Atomic Structure

Queue: Queue is a data framework that have the right to be enforced by using array. The difference in between the stack and queue data framework is that the facets in the queue are put from the rear finish while the facets in the queue are gotten rid of from the prior end.