02 Variables and Types

Vuslat S. Emre
3 min readMar 17, 2020

A variable in Java must be a specified data type.

VARIABLES

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.

IDENTIFIERS

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.

DECLARATIONS AND ASSIGNMENT

double =datatype / radius = variable_name

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

CONSTANTS

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;

EXPRESSIONS

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.

TYPES

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

--

--

Vuslat S. Emre

a young woman who writes about life and what she has learned • software developer • https://bento.me/vuslat