Teaching myself about Java Data Types

I’m on a journey of teaching myself more about Java, and here’s what I learned about Java Data Types…..

The Java programming language is both a statically typed language and a strongly typed language. Statically typed means that every variable, argument, and method must have a type known at compile time. Strongly typed means that once a variable or expression is established with a type then operations on that variable or expression is limited to that type.

In Java, types can be categorized into two divisions:

  • Primitive Data Types
  • Referenced Data Types

Primitive Data Types

The Primitive Data Types are 8 in total:

  • boolean
  • byte
  • char
  • short
  • int
  • long
  • float
  • double

How we can use Java Primitive Data Types:

Non-Primitive Data Types or Referenced Data Types

Non-primitive data types or Reference data types are references to objects (an instance of a class) stored at a memory address with the programmer declared data type.

Java Reference Data Types are:

  • Class
  • Interface
  • Array


Classes are blueprints from which objects can be created. In a class, there are fields and methods that are common to all objects of the class/data type. Class declarations include an access modifier (public, default, protected, private), the name of the class, a super class i.e. Object class, and a body surrounded by two curly braces.


An interface is similar to a class. They are similar to a class because they have fields and methods. However the fields and methods are declared differently. In interfaces all the fields are public static final and all the methods are abstract i.e. they do not have implementation/method bodies. Interfaces are a collection of abstract methods that classes can implement to perform actions or behaviors. When a class implements an interface, the class is signing a contract saying that the class has to take on the methods of the interface and provide method bodies.


An array in java is a container object that holds a fixed number of elements of a single type. Once an array is created, its length is fixed. Each element in the array can be accessed using a numerical index. All indexes in an array starts at 0 and increases until the end of the array is reached. Since array indices start at 0 then the 7th element of the array can be accessed at index 6.

How we can create a class, implement an interface, and use an array:

T'Challa [heroName=Black Panther]jump kick, haa!Sam Wilson [heroName=The Falcon]Ruuunn!Miles Morales [heroName=Spider-Man]power punch, ha!Ororo Munroe [heroName=Storm]Up up and away!

Thanks for taking the time to read this! If you like, share in the comments what you’ve learned about Java Primitive Data Types and Reference Data Types! :)

Self-Taught Developer | On the journey of mastery

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store