You are on page 1of 27

Concepts of data types in java

A data typein a programming


language is a set of data with values
having predefined characteristics
Tokens

Each individual character in java


program

Tokens Java
Types of Tokens
Literals
Punctuators

Identifiers Separators

Assignments
Operators
TOKENS

A = B + 10 ;

ID AS PU
IDE OP
EN SIG LIT NC
NTI ER
TI NM
FIE
ER TU
EN AT
FI R AL AT
T OR
ER OR
Literals

These are constants in java program


The values are fixed
STRING REAL LITERALS
LITERALS

INTEGER CHARACTER
Literals
LITERALS LITERALS

BOOLEAN
NULL LITERALS LITERALS
Integer Literals

The number that are represented


without decimal point
Whole numbers having positive or
negative values
Ex: 16,986,-99,-765
Real literals

Floating point constants


Numbers with decimal points
Ex: 89.7, 0.0098, -3.2267,1.0E-03
Character literal

Constants which are alphanumeric in


character
Alphabets (upper and lower)
Digits
Special characters
Eg: B, f , 4 , *
Character represents a single digit
enclosed within single quotes
String literals

Set of alphanumeric characters


Group of characters enclosed within
double quotes
Eg: Computer year 2012
Boolean literals

They are special literals


They represent true or false and is
applied in logical situation
There will be no quotes
Null literal

It is represented as /0
String terminator
Marks the end of the string
Punctuators

Punctuation signs used as special


characters
Ex: ? ; .
; - Statement terminator
. - scope of a function
Any line continued after semicolon is
treated as next line
Separators

Special characters in java which are


used to separate the variables or the
characters
() [] {}
() to enclose arithmetic or relational
expression
[] to enclose subscript or cell number
of a dimensional array
{} to enclose a group of statements
Escape sequence

Non-graphic characters
They cannot be typed directly from the
keyboard
Begins with a \ followed by one of two
characters
\r - horizontal tab
\v - vertical tab
\b - backspace
Operators

Symbols or tokens
Performs arithmetic or logical
operations
Three types
Arithmetic Operator( +, - , *, /)
Relational Operator(< ,> , <=, >=,
==, <>)
Logical operator ( &&, ||,!)
Data types in Java
INTEGER
S
FLOATING
NUMBER
S

CHARACTERS

BOOLEAN

STRING
Primitive type
Independent on any other type
They are Basic data types
EG: byte,int,long,float, double
NON-Primitive
Derived data types
Directly or indirectly dependent on
primitive data type
They store data data with reference to
the address of locations
They are also called REFERENCE DATA
EG: arrays,classes,interface etc
Initializing a variable
static
Rules for naming a variable

May have any number of characters


Contain alphabets, digits and
underscore
Underscore applied between the
characters to increase the length of
variable name
Name should be meaningful
Arithmetic Expressions
Hierarchy of Data Types

It indicates the increasing order of data type

If two data of different types are operated t


result automatically gets converted to their
higher type
Type conversion
Implicit
Implicit
Data tye gets converted automatically
into its higher type without
intervention of the user
Explicit
When data type gets converted to
another type after user intervention
int a,b;
float x=(float) a+b;

You might also like