0% found this document useful (0 votes)
18 views10 pages

Lecture 5

The document provides an overview of data types in Java, categorizing them into primitive (e.g., boolean, char, int) and non-primitive types (e.g., String, Array). It includes details on syntax for declaring variables and examples of each data type's size, default values, and range. The document serves as a foundational guide for understanding Java programming data types and variable declaration.

Uploaded by

sneha chaudhari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views10 pages

Lecture 5

The document provides an overview of data types in Java, categorizing them into primitive (e.g., boolean, char, int) and non-primitive types (e.g., String, Array). It includes details on syntax for declaring variables and examples of each data type's size, default values, and range. The document serves as a foundational guide for understanding Java programming data types and variable declaration.

Uploaded by

sneha chaudhari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Java programming

Mrs. Sneha D. Patil


Assistant Professor
(E&C Department)
Index

 Data types
 Types of data types
 Primitive data types
 Non primitive data types
 Syntax for declaring variables
 Declaration of variable example
 Giving value to variable
Data types
 Data types in Java are of different sizes
and values that can be stored in the
variable that is made as per convenience
and circumstances to cover up all test
cases. Java has two categories in which
data types are segregated
 Primitive Data Type: such as Boolean,
char, int, short, byte, long, float, and double
 Non-Primitive Data Type or Object
Data type: such as String, Array, etc.
type Description Default Size Example Literals Range of values

boolean true or false false 8 bits true, false true, false

twos-complement
byte 0 8 bits (none) -128 to 127
integer

characters
‘a’, ‘\u0041’, ‘\101’, representation of
char Unicode character \u0000 16 bits
‘\\’, ‘\’, ‘\n’, ‘β’ ASCII values
0 to 255

twos-complement
short 0 16 bits (none) -32,768 to 32,767
integer

-2,147,483,648
twos-complement
int 0 32 bits -2,-1,0,1,2 to
intger
2,147,483,647

-
9,223,372,036,854,77
twos-complement 5,808
long 0 64 bits -2L,-1L,0L,1L,2L
integer to
9,223,372,036,854,77
5,807

IEEE 754 floating 1.23e100f , -1.23e-


float 0.0 32 bits upto 7 decimal digits
point 100f , .3f ,3.14F

IEEE 754 floating 1.23456e300d , -


double 0.0 64 bits upto 16 decimal d
point 123456e-300d , 1e1d
Non primitive data types
Syntax for declaring variable
 To create a variable, you must specify the
type and assign it a value:
 Syntax:
 type variableName = value;
 Where type is one of Java's types (such
as int or String), and variableName is the
name of the variable (such
as x or name). The equal sign is used to
assign values to the variable.
Declaration of variables
Giving values to variables
THANK YOU….

TO BE CONTINUE……

You might also like