• Home
  • Java
    • Java Basics
  • Kafka
    • Producer
  • AWS
  • GoLang
  • About Me
mjpric3@gmail.com
Curriculum Vitae

The Code Standard

  • Home
  • Java
    • Java Basics
  • Kafka
    • Producer
  • AWS
  • GoLang
  • About Me

Java Data Types

Basics

There are two different data types in Java. Reference and Primitives.

Primitive Types

There are eight primitive types: Before we defined the size of these primitives, let’s first define what a bit is. A bit stands for binary digit. A bit is the smallest unit of data in a computer. Its value can either be a 1 or 0. (True, False)

Primitive Data TypeNumber of Bits
byte8 (Integral Value)
char16 (Unicode Value)
short16 (Integral Value)
int32 (Integral Value)
long64 (Integral Value)
float32 (Floating-Point Value)
double64 (Floating-Point Value)
booleanTrue or False

Here are some examples of declaring and initializing all of these types.

byte b = 1;

char c = 'c';

short s = 1;

int n = 100;

long l = 200L;

float f = 100.1f;

double d = 100.1;

boolean flag = true;

Reference Types

A reference type  refers to an instance of a class. If you remember from my previous post that a class instance is called an object. A reference type points to the location in memory where the objects lives. The reference variable stores the memory address where the objects is located.

Will use the String object as an example:

String name = "Mike"; 
// name is the reference object and can only point to a String object.

You also might be interested in

What Is A Computer?

Dec 21, 2018

First we will start off with the dictionary definition of[...]

Producer

Jan 12, 2025

What is a Kafka Producer?

Polymorphism

Jan 3, 2019

Polymorphism is a key component of Java’s Object Oriented Nature.[...]

Recent Posts

  • Producer
  • Interfaces
  • Abstraction
  • Polymorphism
  • Conditional Statements

Categories

  • Basics
  • Kafka
  • Welcome

© 2026 · thecodestandard.com

Prev Next