0% found this document useful (0 votes)
78 views

Primitive Data Types

This document discusses primitive data types, operators, and variables in Java. It describes logical, textual, integral, and floating point data types. Arithmetic operators like addition, subtraction, multiplication, and division are covered. Relational operators for comparison are also outlined. Finally, it defines what a variable is and how to declare one in Java by specifying its data type, name, and optional initial value.

Uploaded by

Janelle Calle
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views

Primitive Data Types

This document discusses primitive data types, operators, and variables in Java. It describes logical, textual, integral, and floating point data types. Arithmetic operators like addition, subtraction, multiplication, and division are covered. Relational operators for comparison are also outlined. Finally, it defines what a variable is and how to declare one in Java by specifying its data type, name, and optional initial value.

Uploaded by

Janelle Calle
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Primitive Data Types,

Operators, and Variables


 Logical
 boolean - represents two states: true or false
 Textual
 char - represents a single 16-bit Unicode character
 Integral
 byte - an 8 bits integer length
 short - a 16 bits integer length
 int - 32 bits integer length
 long - 64 bits integer length
 Floating Point
 float – 32 bits float length
 Double – 64 bits float length
Arithmetic Operators

Operator Use Description


+ op1 + op2 Adds op1 + op2
* op1 * op2 Multiplies op1 by op2
/ op1 / op2 Divide op1 by op2
% op1 % op2 Computes the remainder
of dividing op1 by op2
- op1 -op2 Subtracts op2 from op1
Relational Operators

Operator Use Description


> op1 > op2 op1 is greater than op2
>= op1 >= op2 op1 is greater than or
equal to op2
< op1 <op2 op1 is less than op2
<= op1 <= op2 op1 is less than or equal to
op2
== op1 ==op2 op1 and op2 are equal
!= op1 != op2 Op1 and op2 are not equal
Variables

A variable is an item of data used to store state of objects.


It has a data type and a name. The data type indicates the
type of value that the variable can hold. The variable name
must follow rules for identifiers.
To declare a variable is as follows:
<data type> <name> [=initial value];

You might also like