reference type vs primitive type

Solutions on MaxInterview for reference type vs primitive type by the best coders in the world

showing results for - "reference type vs primitive type"
Yannik
13 Nov 2019
1// The value of primitive data types are directly stored in the memory.
2// For example if int a is initilized to 11, then 11 is directly stored
3// in the memory.
4int a = 11; // Primitive Type 
5
6// Reference types on the other hand are a reference to values in the
7// memory. For example Integer(11) creates a reference in the memory
8// whever the value 11 is stored and passes that memory reference/
9// (address) to the variable.
10Integer b = new Integer(11); // Reference Type 
Maina
12 Mar 2018
1int a = 11; // Primitive Type 
2
3Integer b = new Integer(11); // Reference Type 
4
Austen
09 May 2019
1+================+=========+===================================================================================+
2| Primitive type | Size    | Description                                                                       |
3+================+=========+===================================================================================+
4| byte           | 1 byte  | Stores whole numbers from -128 to 127                                             |
5+----------------+---------+-----------------------------------------------------------------------------------+
6| short          | 2 bytes | Stores whole numbers from -32,768 to 32,767                                       |
7+----------------+---------+-----------------------------------------------------------------------------------+
8| int            | 4 bytes | Stores whole numbers from -2,147,483,648 to 2,147,483,647                         |
9+----------------+---------+-----------------------------------------------------------------------------------+
10| long           | 8 bytes | Stores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
11+----------------+---------+-----------------------------------------------------------------------------------+
12| float          | 4 bytes | Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits           |
13+----------------+---------+-----------------------------------------------------------------------------------+
14| double         | 8 bytes | Stores fractional numbers. Sufficient for storing 15 decimal digits               |
15+----------------+---------+-----------------------------------------------------------------------------------+
16| char           | 2 bytes | Stores a single character/letter or ASCII values                                  |
17+----------------+---------+-----------------------------------------------------------------------------------+
18| boolean        | 1 bit   | Stores true or false values                                                       |
19+----------------+---------+-----------------------------------------------------------------------------------+
queries leading to this page
what is the difference between primitive and reference types 3f javaprimitive vs reference data typesprimitive types vs reference typesprimitives and references in javachar not reference type javawhat is the difference between primitive and reference typesprimitive types vs reference types javaprimitive vs reference types 3fis a primitive type a reference typeprimitive vs typestwo types in java primitive and refprimitive type vs reference typejava data types primitive and referenceprimitive vs referenceprimitive types and reference typesprimitive data type vs reference data typestring reference vs primitiveprimitive types versus reference typesreference type of char in javareference data type vs primitive data typeprimitive variable vs reference variablewhat is primitive and reference typesprimitve types vs reference types javaprimitive data types vs difference between primitive type and reference type 3fprimitive vs reference typewhen analyzing the relationship between primitive and reference data types 2c are created from the other reference type vs primitive type javawhat is the difference between primitive variables and reference variables 3freference and primitive typesclass type vs primitivejava primitive types vs reference typesdifference between primitive types and referance typesdifferences between primitive and reference variablesexplain the difference between a primitive and a reference type reference type vs primitive typejava primitive types and reference typesprimitive vs reference types javaprimitive types vsjava primitive type vs reference typereference type primitiveprimitive type vs reference type javadifference between primitive type and reference type 3f your answerprimitive type reference typeprimitive vs reference types what is the difference between primitive type and reference type in javawhat is the difference between primitive and reference types 3fprimitive type vs reference typedifference reference type and primitivereference vs primitive data typewhat 27s the difference between reference type and primitive typereference types vs primitive typesdifference between reference data types and primitive data types 3fwhat is the difference between primitive data type and reference data typesprimitive data types vs reference data typesdo primitive data types have a reference in javajava reference type vs primitivereference type vs primitive type