SlideShare a Scribd company logo
JAVA DATATYPES
By : Abhishek Mondal
Variables In Java
■ //declaring a variable x of type
//integer and assigned value
■ //30 int x = 30;
■ //declaring a variable c of type
//character and assigned value //‘r’
Char b = ‘r’;
■ A variable is a named field
containing information that your
program uses.You can also think of
a variable as a name of memory
location where the variable value is
stored.
■ In Java, a variable has to be
declared before it is used.
DataTypes
DataTypes refer to the type of data you will store in a
variable. For example a variable can be of type number, string
or an object of a custom class
Primitive And Non-PrimitiveTypes
A primitive data type is pre-built or defined by the
programming language, in this case Java.The size and type of
variable values are fixed and you do not have to do anything
special to use them.
Non-primitive, or reference data types, don't store the value,
but store a reference to that value. Reference data types can be
String , array, class or interface
DataTypes In Java
Primitive DataTypes
Integers
■ There are 4 types of integer data types in Java – byte, short, int, long.
■ //A byte type variable takes 1 byte of storage and can store values from -128 to 127
byte a = 2;
■ //The short data type is a 16-bit. It has a minimum value of -32,768 and a maximum
value of 32,767 short b = 156;
■ //The int data type is a 32-bit signed two’s complement integer, taking values from -
2^31 to 2^31-1 int c = 32769;
■ //The long data type is a 64 bit 'two's complement integer taking values from -2^63 to
2^63- long l = 24678822;
Floating Points
■ There are 2 types of floating point data types in Java – double and float.
■ Single-precision 32-bit IEEE 754 floating point. Its value range is unlimited. float f =
56.8929929;
■ double data type is a double-precision 64-bit IEEE 754 floating point. Its value range is
unlimited. double d = 4.54877;
DoubleVs Float In Java
The Boolean Datatype
■ A boolean type is declared with the boolean keyword and only takes the values true or
false
■ boolean isSaladHealthy = true
■ boolean isSaladTasty = false
■ System.out.println(isSaladHealthy); // Outputs true
■ System.out.println(isSaladTasty); // Outputs false
The Char Datatype
■ The char data type is a single 16-bit Unicode character. A char
is a single character:
■ char grade = ‘A’;
■ System.out.println(grade); // Outputs A
The Non-Primitive Datatype
Class – Defining custom data types
■ A class is a data type in Java that defines a
template or blueprint for an object. In other words
a class refers to the category or type of objects. A
class allows you to declare custom data types.
■ For example you can define a class cat or car or
savings accounts to store objects of specific types.
A class has variables defining properties and
methods defining behavior of its objects.
Class Syntax
Strings In Java
■ A String in Java, representing a collection of characters, is actually an object of type
java.lang.String.The class contains methods that can perform certain operations on
strings.
■ String s = “hello”;
■ System.out.println(“The length of s is ” + s.length());//outputsThe length of s is 5
Arrays In Java
■ Arrays are used to store multiple homogeneous values in a single variable. Note, in
Java array indexes start from zero.
■ String fruits[] = {“apple”,“banana”,”mango”};
■ System.out.println(“The third fruit is” + fruits[2]); //outputsThe third fruit is mango
Interface
■ An interface in Java is used to specify the contract or capabilities that implementing
classes must implement. An interface has abstract methods, with only signatures,
which are then implemented by some classes. For example, every corporate
department may implement the Security Interface.
■ interface Security {
boolean accessCheck(String employeeToken);
}

More Related Content

What's hot

Operators in java
Operators in javaOperators in java
Operators in java
Muthukumaran Subramanian
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
SURIT DATTA
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Madishetty Prathibha
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
Nilesh Dalvi
 
Exception handling in c++
Exception handling in c++Exception handling in c++
Exception handling in c++
imran khan
 
Operators in java
Operators in javaOperators in java
Operators in java
Madishetty Prathibha
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
Niloy Saha
 
String in java
String in javaString in java
Methods in Java
Methods in JavaMethods in Java
Methods in Java
Jussi Pohjolainen
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
Abhilash Nair
 
Constructors in C++
Constructors in C++Constructors in C++
Constructors in C++
RubaNagarajan
 
Vectors in Java
Vectors in JavaVectors in Java
Vectors in Java
Abhilash Nair
 
Data types
Data typesData types
Data types
myrajendra
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
Hitesh Kumar
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
Java2Blog
 
Exceptions in Java
Exceptions in JavaExceptions in Java
Exceptions in Java
Vadym Lotar
 
Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++
Janki Shah
 
Java IO
Java IOJava IO
Java IO
UTSAB NEUPANE
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Elizabeth alexander
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
Farooq Baloch
 

What's hot (20)

Operators in java
Operators in javaOperators in java
Operators in java
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
Exception handling in c++
Exception handling in c++Exception handling in c++
Exception handling in c++
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
String in java
String in javaString in java
String in java
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
 
Constructors in C++
Constructors in C++Constructors in C++
Constructors in C++
 
Vectors in Java
Vectors in JavaVectors in Java
Vectors in Java
 
Data types
Data typesData types
Data types
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
 
Exception Handling in Java
Exception Handling in JavaException Handling in Java
Exception Handling in Java
 
Exceptions in Java
Exceptions in JavaExceptions in Java
Exceptions in Java
 
Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++Exception Handling in object oriented programming using C++
Exception Handling in object oriented programming using C++
 
Java IO
Java IOJava IO
Java IO
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 

Similar to Java data types

Java Data Types
Java Data TypesJava Data Types
Java Data Types
Spotle.ai
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
Jayfee Ramos
 
Md03 - part3
Md03 - part3Md03 - part3
Md03 - part3
Rakesh Madugula
 
Java session3
Java session3Java session3
Java session3
Jigarthacker
 
Introduction to java Programming Language
Introduction to java Programming LanguageIntroduction to java Programming Language
Introduction to java Programming Language
rubyjeyamani1
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
Javed Rashid
 
Identifiers, keywords and types
Identifiers, keywords and typesIdentifiers, keywords and types
Identifiers, keywords and types
Daman Toor
 
CSC111-Chap_02.pdf
CSC111-Chap_02.pdfCSC111-Chap_02.pdf
CSC111-Chap_02.pdf
2b75fd3051
 
Lec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdf
Lec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdfLec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdf
Lec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdf
RahulKumar342376
 
JAVA LESSON-01.pptx
JAVA LESSON-01.pptxJAVA LESSON-01.pptx
JAVA LESSON-01.pptx
StephenOczon1
 
C language basics
C language basicsC language basics
C language basics
Nikshithas R
 
Array lecture
Array lectureArray lecture
Array lecture
Joan Saño
 
Learning core java
Learning core javaLearning core java
Learning core java
Abhay Bharti
 
Java - Basic Datatypes.pptx
Java - Basic Datatypes.pptxJava - Basic Datatypes.pptx
Java - Basic Datatypes.pptx
Nagaraju Pamarthi
 
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdfL2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
MMRF2
 
3 jf h-linearequations
3  jf h-linearequations3  jf h-linearequations
3 jf h-linearequations
AboutHydrology Slides
 
Core Java Programming Language (JSE) : Chapter III - Identifiers, Keywords, ...
Core Java Programming Language (JSE) : Chapter III -  Identifiers, Keywords, ...Core Java Programming Language (JSE) : Chapter III -  Identifiers, Keywords, ...
Core Java Programming Language (JSE) : Chapter III - Identifiers, Keywords, ...
WebStackAcademy
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
Harshita Yadav
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
YRABHI
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
Mufaddal Nullwala
 

Similar to Java data types (20)

Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Md03 - part3
Md03 - part3Md03 - part3
Md03 - part3
 
Java session3
Java session3Java session3
Java session3
 
Introduction to java Programming Language
Introduction to java Programming LanguageIntroduction to java Programming Language
Introduction to java Programming Language
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
 
Identifiers, keywords and types
Identifiers, keywords and typesIdentifiers, keywords and types
Identifiers, keywords and types
 
CSC111-Chap_02.pdf
CSC111-Chap_02.pdfCSC111-Chap_02.pdf
CSC111-Chap_02.pdf
 
Lec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdf
Lec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdfLec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdf
Lec-2- Ehsjdjkck. Jdkdbd djskrogramming.pdf
 
JAVA LESSON-01.pptx
JAVA LESSON-01.pptxJAVA LESSON-01.pptx
JAVA LESSON-01.pptx
 
C language basics
C language basicsC language basics
C language basics
 
Array lecture
Array lectureArray lecture
Array lecture
 
Learning core java
Learning core javaLearning core java
Learning core java
 
Java - Basic Datatypes.pptx
Java - Basic Datatypes.pptxJava - Basic Datatypes.pptx
Java - Basic Datatypes.pptx
 
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdfL2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
 
3 jf h-linearequations
3  jf h-linearequations3  jf h-linearequations
3 jf h-linearequations
 
Core Java Programming Language (JSE) : Chapter III - Identifiers, Keywords, ...
Core Java Programming Language (JSE) : Chapter III -  Identifiers, Keywords, ...Core Java Programming Language (JSE) : Chapter III -  Identifiers, Keywords, ...
Core Java Programming Language (JSE) : Chapter III - Identifiers, Keywords, ...
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
 

More from AbhishekMondal42

Oss evaluation-certification-oss-financial-advantages
Oss evaluation-certification-oss-financial-advantagesOss evaluation-certification-oss-financial-advantages
Oss evaluation-certification-oss-financial-advantages
AbhishekMondal42
 
Word press 01
Word press 01Word press 01
Word press 01
AbhishekMondal42
 
Word press posts(preview & publish)
Word press posts(preview & publish)Word press posts(preview & publish)
Word press posts(preview & publish)
AbhishekMondal42
 
Word press posts(add , edit , delete post)
Word press posts(add , edit , delete post)Word press posts(add , edit , delete post)
Word press posts(add , edit , delete post)
AbhishekMondal42
 
Word press pages(edit and delete)
Word press pages(edit and delete)Word press pages(edit and delete)
Word press pages(edit and delete)
AbhishekMondal42
 
Word press pages(add)
Word press pages(add)Word press pages(add)
Word press pages(add)
AbhishekMondal42
 
Word press media(add,insert,delete)
Word press media(add,insert,delete)Word press media(add,insert,delete)
Word press media(add,insert,delete)
AbhishekMondal42
 
Word press media library
Word press media libraryWord press media library
Word press media library
AbhishekMondal42
 
Word press widget management
Word press  widget managementWord press  widget management
Word press widget management
AbhishekMondal42
 
Word press view plugins
Word press  view pluginsWord press  view plugins
Word press view plugins
AbhishekMondal42
 
Word press user roles
Word press  user rolesWord press  user roles
Word press user roles
AbhishekMondal42
 
Word press theme management
Word press  theme managementWord press  theme management
Word press theme management
AbhishekMondal42
 
Word press personal profile
Word press  personal profileWord press  personal profile
Word press personal profile
AbhishekMondal42
 
Word press moderate comments
Word press  moderate commentsWord press  moderate comments
Word press moderate comments
AbhishekMondal42
 
Word press install plugins
Word press  install pluginsWord press  install plugins
Word press install plugins
AbhishekMondal42
 
Word press edit users
Word press  edit usersWord press  edit users
Word press edit users
AbhishekMondal42
 
Word press edit tags
Word press  edit tagsWord press  edit tags
Word press edit tags
AbhishekMondal42
 
Word press edit links
Word press  edit linksWord press  edit links
Word press edit links
AbhishekMondal42
 
Word press edit comments
Word press  edit commentsWord press  edit comments
Word press edit comments
AbhishekMondal42
 
Word press delete users
Word press  delete usersWord press  delete users
Word press delete users
AbhishekMondal42
 

More from AbhishekMondal42 (20)

Oss evaluation-certification-oss-financial-advantages
Oss evaluation-certification-oss-financial-advantagesOss evaluation-certification-oss-financial-advantages
Oss evaluation-certification-oss-financial-advantages
 
Word press 01
Word press 01Word press 01
Word press 01
 
Word press posts(preview & publish)
Word press posts(preview & publish)Word press posts(preview & publish)
Word press posts(preview & publish)
 
Word press posts(add , edit , delete post)
Word press posts(add , edit , delete post)Word press posts(add , edit , delete post)
Word press posts(add , edit , delete post)
 
Word press pages(edit and delete)
Word press pages(edit and delete)Word press pages(edit and delete)
Word press pages(edit and delete)
 
Word press pages(add)
Word press pages(add)Word press pages(add)
Word press pages(add)
 
Word press media(add,insert,delete)
Word press media(add,insert,delete)Word press media(add,insert,delete)
Word press media(add,insert,delete)
 
Word press media library
Word press media libraryWord press media library
Word press media library
 
Word press widget management
Word press  widget managementWord press  widget management
Word press widget management
 
Word press view plugins
Word press  view pluginsWord press  view plugins
Word press view plugins
 
Word press user roles
Word press  user rolesWord press  user roles
Word press user roles
 
Word press theme management
Word press  theme managementWord press  theme management
Word press theme management
 
Word press personal profile
Word press  personal profileWord press  personal profile
Word press personal profile
 
Word press moderate comments
Word press  moderate commentsWord press  moderate comments
Word press moderate comments
 
Word press install plugins
Word press  install pluginsWord press  install plugins
Word press install plugins
 
Word press edit users
Word press  edit usersWord press  edit users
Word press edit users
 
Word press edit tags
Word press  edit tagsWord press  edit tags
Word press edit tags
 
Word press edit links
Word press  edit linksWord press  edit links
Word press edit links
 
Word press edit comments
Word press  edit commentsWord press  edit comments
Word press edit comments
 
Word press delete users
Word press  delete usersWord press  delete users
Word press delete users
 

Recently uploaded

220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
Kalna College
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
Nguyen Thanh Tu Collection
 
Information and Communication Technology in Education
Information and Communication Technology in EducationInformation and Communication Technology in Education
Information and Communication Technology in Education
MJDuyan
 
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
ShwetaGawande8
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
Mohammad Al-Dhahabi
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
MJDuyan
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Kalna College
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
Celine George
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
Kalna College
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
Kalna College
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
Celine George
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
indexPub
 
adjectives.ppt for class 1 to 6, grammar
adjectives.ppt for class 1 to 6, grammaradjectives.ppt for class 1 to 6, grammar
adjectives.ppt for class 1 to 6, grammar
7DFarhanaMohammed
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
Kalna College
 

Recently uploaded (20)

220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology220711130097 Tulip Samanta Concept of Information and Communication Technology
220711130097 Tulip Samanta Concept of Information and Communication Technology
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
 
Information and Communication Technology in Education
Information and Communication Technology in EducationInformation and Communication Technology in Education
Information and Communication Technology in Education
 
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) CurriculumPhilippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
Philippine Edukasyong Pantahanan at Pangkabuhayan (EPP) Curriculum
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
 
220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx220711130088 Sumi Basak Virtual University EPC 3.pptx
220711130088 Sumi Basak Virtual University EPC 3.pptx
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
220711130100 udita Chakraborty  Aims and objectives of national policy on inf...220711130100 udita Chakraborty  Aims and objectives of national policy on inf...
220711130100 udita Chakraborty Aims and objectives of national policy on inf...
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
 
adjectives.ppt for class 1 to 6, grammar
adjectives.ppt for class 1 to 6, grammaradjectives.ppt for class 1 to 6, grammar
adjectives.ppt for class 1 to 6, grammar
 
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
220711130083 SUBHASHREE RAKSHIT  Internet resources for social science220711130083 SUBHASHREE RAKSHIT  Internet resources for social science
220711130083 SUBHASHREE RAKSHIT Internet resources for social science
 

Java data types

  • 1. JAVA DATATYPES By : Abhishek Mondal
  • 2. Variables In Java ■ //declaring a variable x of type //integer and assigned value ■ //30 int x = 30; ■ //declaring a variable c of type //character and assigned value //‘r’ Char b = ‘r’; ■ A variable is a named field containing information that your program uses.You can also think of a variable as a name of memory location where the variable value is stored. ■ In Java, a variable has to be declared before it is used.
  • 3. DataTypes DataTypes refer to the type of data you will store in a variable. For example a variable can be of type number, string or an object of a custom class
  • 4. Primitive And Non-PrimitiveTypes A primitive data type is pre-built or defined by the programming language, in this case Java.The size and type of variable values are fixed and you do not have to do anything special to use them. Non-primitive, or reference data types, don't store the value, but store a reference to that value. Reference data types can be String , array, class or interface
  • 7. Integers ■ There are 4 types of integer data types in Java – byte, short, int, long. ■ //A byte type variable takes 1 byte of storage and can store values from -128 to 127 byte a = 2; ■ //The short data type is a 16-bit. It has a minimum value of -32,768 and a maximum value of 32,767 short b = 156; ■ //The int data type is a 32-bit signed two’s complement integer, taking values from - 2^31 to 2^31-1 int c = 32769; ■ //The long data type is a 64 bit 'two's complement integer taking values from -2^63 to 2^63- long l = 24678822;
  • 8. Floating Points ■ There are 2 types of floating point data types in Java – double and float. ■ Single-precision 32-bit IEEE 754 floating point. Its value range is unlimited. float f = 56.8929929; ■ double data type is a double-precision 64-bit IEEE 754 floating point. Its value range is unlimited. double d = 4.54877;
  • 10. The Boolean Datatype ■ A boolean type is declared with the boolean keyword and only takes the values true or false ■ boolean isSaladHealthy = true ■ boolean isSaladTasty = false ■ System.out.println(isSaladHealthy); // Outputs true ■ System.out.println(isSaladTasty); // Outputs false
  • 11. The Char Datatype ■ The char data type is a single 16-bit Unicode character. A char is a single character: ■ char grade = ‘A’; ■ System.out.println(grade); // Outputs A
  • 13. Class – Defining custom data types ■ A class is a data type in Java that defines a template or blueprint for an object. In other words a class refers to the category or type of objects. A class allows you to declare custom data types. ■ For example you can define a class cat or car or savings accounts to store objects of specific types. A class has variables defining properties and methods defining behavior of its objects.
  • 15. Strings In Java ■ A String in Java, representing a collection of characters, is actually an object of type java.lang.String.The class contains methods that can perform certain operations on strings. ■ String s = “hello”; ■ System.out.println(“The length of s is ” + s.length());//outputsThe length of s is 5
  • 16. Arrays In Java ■ Arrays are used to store multiple homogeneous values in a single variable. Note, in Java array indexes start from zero. ■ String fruits[] = {“apple”,“banana”,”mango”}; ■ System.out.println(“The third fruit is” + fruits[2]); //outputsThe third fruit is mango
  • 17. Interface ■ An interface in Java is used to specify the contract or capabilities that implementing classes must implement. An interface has abstract methods, with only signatures, which are then implemented by some classes. For example, every corporate department may implement the Security Interface. ■ interface Security { boolean accessCheck(String employeeToken); }