02 Variables and Types

A variable in Java must be a specified data type.


A variable is any characteristics, number, or quantity that can be measured or counted. A variable may also be called a data item.

A varibale has:

  • name
  • a type
  • a storage location for the variable’s value.


An identifier is simply the name of a program or the names of the variables within a program that are used to identify the relevant data/info. Typically, identifiers must start with a letter and must not have any spaces in them.


double =datatype / radius = variable_name

To use a variable in your program, you need to first “introduce” it by declaring its name and type.


In computer programming, a constant is a value that cannot be altered by the program during normal execution the value is constant. …

final datatype CONSTANT_NAME = VALUE;


Language is a combination of one or more constants, variables, operators, and functions that the programming language interprets (according to its particular rules of precedence and of association) and computes to produce (“to return”, in a stateful environment) another value.


Java has primitive types and reference types(non-primitive);

Primitive Data Types

Java has 8 primitive types

ranges of these types

Non-Primitive Data Types
Non-primitive data types are called reference types because they refer to objects.

example:strings, arrays….

The main difference between primitive and non-primitive data types are:

  • Primitive types are predefined (already defined) in Java. Non-primitive types are created by the programmer and is not defined by Java (except for String).
    -A primitive type has always a value, while non-primitive types can be null.
    -A primitive type starts with a lowercase letter, while non-primitive types starts with an uppercase letter.
    -Non-primitive types can be used to call methods to perform certain operations, while primitive types cannot.
    -The size of a primitive type depends on the data type, while non-primitive types have all the same size.

references: https://www.w3schools.com/java/java_data_types.asp

previous: https://vuslats.medium.com/01-introduction-to-java-programming-aa62c2656d31




Software Developer | my universe: https://twitter.com/NightmaresTown

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Installing MariaDB and connecting it to Python on Fedora Workstation 33

A test run with Mintlify AI Doc Writer

Automated tests: why should I care about them and which ones should I use?

Clutch Recognizes Southern Code as One of the Top B2B Companies in Argentina

OpenShift and its use-cases

C# 7 First Look

How get the latest earthquake data With Python.

Hacktober Fest what? I am in HNG!!

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


Software Developer | my universe: https://twitter.com/NightmaresTown

More from Medium

Java Reflection, part 2: fields, methods, constructors

Head First Java (Chapter 04) How Objects Behave

Builder Design Pattern

Find Articulation Point in a Graph