get a quote
Sales: +91-9871296565,
sales@netscapeindia.com
What are the primitive data and Atomic primitive data in java

What are the primitive data and Atomic primitive data in java

Primitive data are the fundamental building blocks of a computer language. The primitive data in Java are numbers, characters, strings and Booleans. Numbers can be integers or floating point numbers. Characters are single letters, digits and symbols. Strings can be text or any other sequence of characters. Booleans represent true or false values.

Atomic primitive data is a single entity that cannot be broken down any further. Examples of atomic primitive data include numbers, words, and characters. Composite primitive data is a group of related entities that can be broken down into their individual parts. Examples of composite primitive data include images, videos, and databases.

In java, data types are classified into two categories:

  • Primitive Data type or Intrinsic or built-in data type
  • Non-Primitive Data type or derived  or reference data type

Primitive data are the building blocks that make up all data. They are the basic, fundamental types of data. There are mine primitive types of data:

  • byte – represent text, It is an 8-bit quantity that can be stored in one byte. It is an 8-bit quantity that can be stored in one byte. Value range from -128 to 127. Default value zero.
  • char – It is a type of variable. It is a single-character 16-bit Unicode character.
  • Number – a decimal number;
  • Boolean – either true or false;
  • Date and Time – a specific point in time;
  • Geographical Point – an exact location on Earth, such as a city, country, or longitude/latitude; and
  • Binary Data – raw bytes of information.
  • Short – refers to a value that is shorter than the other values, 2bytes (16-bit) integer.
  • long- Generated by the continuous streams of data, it has an infinite length. 8bytes(64-bites) integer.

In Java, a non-primitive data type is any data type that is not a primitive and created by programme, and Non-Primitive data type is a data type that does not belong to the primitive types.

The non-Primitive data type can be one of the following:

  • Class- a class is a blueprint for an object that defines what it looks like and the operations that can be performed on it.

  • Arrays- the Array class as a built-in type for storing an ordered sequence of elements and manipulating those elements. An array is often used to represent the rows in an Excel spreadsheet, or the columns in a database table.

Arrays have three important properties:

1) The size of the array can be determined at compile time by an annotation

2) The size of the array can be fixed at runtime by using newInstance()

3) The size of the array can be variable at runtime by using newInstance() and setting its length field

The following examples show how to create an array with both single-dimensional and multidimensional arrays:

//Single-dimensional array

int[] myIntArray = {1, 2, 3};

// Multidimensional array

int[][] myIntArray2 = {{1, 2}, {3, 4}};

  • String – String is one of the most common data types used in Java. It can be used to represent text and to store text values. String can be created using the new keyword, which allocates memory for it and sets its value to an empty string.
  • int-Integers are used to represent integers and are stored in a computer as an unsigned 32-bit integer. Integers are often used to represent lengths, distances, and other quantities that can be measured on a scale of 0 to 16,777,215.,. Integers can be represented as binary, octal, decimal, or hexadecimal.

No Comments

Post a Comment

Comment
Name
Email
Website