SlideShare a Scribd company logo
1 of 15
Variables & Data Types
Dr. M H B Ariyaratne
https://goo.gl/ytyvLS
Variables
● Reserved memory locations to store values
● When we create a variable we reserve some space in
memory.
● Based on the datatype of a variable, the operating
system allocates memory and decides what can be
stored in the reserved memory.
● By assigning different data types to variables, we can
store integers, decimals, or characters in these variables
Types of Variables
Primitive Data Types
Reference/Object Data Types
Primitive Data Types
Predefined by the language
Named by a keyword
Java - eight primitive data types
Naming variables in JAVA
● Variable names are case-sensitive
● An unlimited-length sequence of Unicode letters and digits
● Beginning with a letter, the dollar sign "$", or the underscore character "_"
● White space is not permitted
● Subsequent characters may be letters, digits, dollar signs, or underscore
characters.
● Use full words instead of cryptic abbreviations.
● Must not be a keyword or reserved word.
● If only one word, spell that word in all lowercase letters
● If more than one word, capitalize the first letter of each subsequent word.
● If your variable stores a constant value capitalizing every letter and
Primitive Data Types - byte
● Byte data type is an 8-bit signed two's complement
integer
● Minimum value is -128 (-27)
● Maximum value is 127 (inclusive)(27 -1)
● Default value is 0
● Byte data type is used to save space in large arrays,
mainly in place of integers
● Example: byte a = 100 , byte b = -50
Primitive Data Types - short
● 16-bit signed two's complement integer.
● Minimum value is -32,768 (-215)
● Maximum value is 32,767 (inclusive) (215 -1)
● Short data type can also be used to save memory as byte
data type. A short is 2 times smaller than an int
● Default value is 0.
● Example: short s = 10000, short r = -20000
Primitive Data Type - int
● A 32-bit signed two's complement integer.
● Minimum value is - 2,147,483,648.(-231)
● Maximum value is 2,147,483,647(inclusive).(231 -1)
● int is generally used as the default data type for integral
values unless there is a concern about memory
● The default value is 0.
● Example: int a = 100000, int b = -200000
Primitive Data Type - long
● A 64-bit signed two's complement integer.
● Minimum value is -9,223,372,036,854,775,808.(-263)
● Maximum value is 9,223,372,036,854,775,807 (inclusive).
(263 -1)
● This type is used when a wider range than int is needed.
● Default value is 0L.
● Example: long a = 100000L, int b = -200000L
Primitive Data Types - float
● A single-precision 32-bit IEEE 754 floating point.
● Float is mainly used to save memory in large arrays of
floating point numbers.
● Default value is 0.0f.
● Example: float f1 = 234.5f
Primitive Data Types - double
● A double-precision 64-bit IEEE 754 floating point.
● Generally used as the default data type for decimal
values
● Default value is 0.0d.
● Example: double d1 = 123.4
Primitive Data Types - boolean
● Represents one bit of information.
● There are only two possible values: true and false.
● This data type is used for simple flags that track
true/false conditions.
● Default value is false.
● Example: boolean one = true
Primitive Data Types - char
● A single 16-bit Unicode character.
● Minimum value is 'u0000' (or 0).
● Maximum value is 'uffff' (or 65,535 inclusive).
● Char data type is used to store any character.
● Example: char letterA ='A'
Reference Data Types
We will discuss them under as a separate presentation on Objects and Strings.
Thank you

More Related Content

What's hot

Primitive data types
Primitive data typesPrimitive data types
Primitive data typesStudent
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Typesk v
 
Data types in Java
Data types in JavaData types in Java
Data types in JavaPlay Store
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++Neeru Mittal
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programmingHarshita Yadav
 
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...Smit Shah
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6REHAN IJAZ
 
04 data types & variables
04   data types & variables04   data types & variables
04 data types & variablesdhrubo kayal
 
HPEC 2021 sparse binary format
HPEC 2021 sparse binary formatHPEC 2021 sparse binary format
HPEC 2021 sparse binary formatErikWelch2
 
Welcome to our_presentation in c
Welcome to our_presentation in cWelcome to our_presentation in c
Welcome to our_presentation in cimran hasan
 
XPath XQuery Training by Wishtree in India Pune Bangalore Bengaluru Gurgaon ...
XPath  XQuery Training by Wishtree in India Pune Bangalore Bengaluru Gurgaon ...XPath  XQuery Training by Wishtree in India Pune Bangalore Bengaluru Gurgaon ...
XPath XQuery Training by Wishtree in India Pune Bangalore Bengaluru Gurgaon ...Wishtree Technologies
 

What's hot (20)

Lect5
Lect5Lect5
Lect5
 
Data types in C
Data types in CData types in C
Data types in C
 
Primitive data types
Primitive data typesPrimitive data types
Primitive data types
 
Data type
Data typeData type
Data type
 
Datatypes in c
Datatypes in cDatatypes in c
Datatypes in c
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Unit4 C
Unit4 C Unit4 C
Unit4 C
 
Data types in Java
Data types in JavaData types in Java
Data types in Java
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Lect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer AbbasLect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer Abbas
 
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
Basic of Structure,Structure members,Accessing Structure member,Nested Struct...
 
Programming Fundamentals lecture 6
Programming Fundamentals lecture 6Programming Fundamentals lecture 6
Programming Fundamentals lecture 6
 
04 data types & variables
04   data types & variables04   data types & variables
04 data types & variables
 
Data types
Data typesData types
Data types
 
Structure in c
Structure in cStructure in c
Structure in c
 
Data types
Data typesData types
Data types
 
HPEC 2021 sparse binary format
HPEC 2021 sparse binary formatHPEC 2021 sparse binary format
HPEC 2021 sparse binary format
 
Welcome to our_presentation in c
Welcome to our_presentation in cWelcome to our_presentation in c
Welcome to our_presentation in c
 
XPath XQuery Training by Wishtree in India Pune Bangalore Bengaluru Gurgaon ...
XPath  XQuery Training by Wishtree in India Pune Bangalore Bengaluru Gurgaon ...XPath  XQuery Training by Wishtree in India Pune Bangalore Bengaluru Gurgaon ...
XPath XQuery Training by Wishtree in India Pune Bangalore Bengaluru Gurgaon ...
 

Similar to 5. variables & data types

java programming basics - part ii
 java programming basics - part ii java programming basics - part ii
java programming basics - part iijyoti_lakhani
 
Unit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.pptUnit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.pptpubgnewstate1620
 
Java Tutorial Lab 2
Java Tutorial Lab 2Java Tutorial Lab 2
Java Tutorial Lab 2Berk Soysal
 
Data Types and variables in C++.pptx
Data Types and variables in C++.pptxData Types and variables in C++.pptx
Data Types and variables in C++.pptxjamilmalik19
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introductionnikshaikh786
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART IHari Christian
 
Chapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxChapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxlemonchoos
 
introduction to python
 introduction to python introduction to python
introduction to pythonJincy Nelson
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointersSamiksha Pun
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data typesPratik Devmurari
 
2._Java_Syntax_and_Data_Type.pptx.pdf
2._Java_Syntax_and_Data_Type.pptx.pdf2._Java_Syntax_and_Data_Type.pptx.pdf
2._Java_Syntax_and_Data_Type.pptx.pdfluxasuhi
 

Similar to 5. variables & data types (20)

java programming basics - part ii
 java programming basics - part ii java programming basics - part ii
java programming basics - part ii
 
Variable
VariableVariable
Variable
 
Data types
Data typesData types
Data types
 
Java - Basic Datatypes.pptx
Java - Basic Datatypes.pptxJava - Basic Datatypes.pptx
Java - Basic Datatypes.pptx
 
Data types
Data typesData types
Data types
 
Unit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.pptUnit 1 Built in Data types in C language.ppt
Unit 1 Built in Data types in C language.ppt
 
JAVA LESSON-01.pptx
JAVA LESSON-01.pptxJAVA LESSON-01.pptx
JAVA LESSON-01.pptx
 
Java Tutorial Lab 2
Java Tutorial Lab 2Java Tutorial Lab 2
Java Tutorial Lab 2
 
Python Essentials - PICT.pdf
Python Essentials - PICT.pdfPython Essentials - PICT.pdf
Python Essentials - PICT.pdf
 
Data Types and variables in C++.pptx
Data Types and variables in C++.pptxData Types and variables in C++.pptx
Data Types and variables in C++.pptx
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
C language basics
C language basicsC language basics
C language basics
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Data types ,variables,array
Data types ,variables,arrayData types ,variables,array
Data types ,variables,array
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART I
 
Chapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxChapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptx
 
introduction to python
 introduction to python introduction to python
introduction to python
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
2._Java_Syntax_and_Data_Type.pptx.pdf
2._Java_Syntax_and_Data_Type.pptx.pdf2._Java_Syntax_and_Data_Type.pptx.pdf
2._Java_Syntax_and_Data_Type.pptx.pdf
 

More from M H Buddhika Ariyaratne (17)

14. collections
14. collections14. collections
14. collections
 
13. interfaces
13. interfaces13. interfaces
13. interfaces
 
12. arrays
12. arrays12. arrays
12. arrays
 
11. java methods
11. java methods11. java methods
11. java methods
 
10. inheritance
10. inheritance10. inheritance
10. inheritance
 
9. strings
9. strings9. strings
9. strings
 
8. objects & classes
8. objects & classes8. objects & classes
8. objects & classes
 
7. flowcharts and pseudocode
7. flowcharts and pseudocode7. flowcharts and pseudocode
7. flowcharts and pseudocode
 
6. java operators
6. java operators6. java operators
6. java operators
 
4. mathematics for computing
4. mathematics for computing4. mathematics for computing
4. mathematics for computing
 
3. introduction to java
3. introduction to java3. introduction to java
3. introduction to java
 
2. data structures & algorithms
2. data structures & algorithms2. data structures & algorithms
2. data structures & algorithms
 
1. introduction mathematics for computing and object oriented programming
1. introduction   mathematics for computing  and  object oriented programming1. introduction   mathematics for computing  and  object oriented programming
1. introduction mathematics for computing and object oriented programming
 
Gis for healthcare introduction
Gis for healthcare   introductionGis for healthcare   introduction
Gis for healthcare introduction
 
Open hospital management information system
Open hospital management information systemOpen hospital management information system
Open hospital management information system
 
Who am i and what i have done
Who am i and what i have doneWho am i and what i have done
Who am i and what i have done
 
Electronic health record system for sri lankan general practitioners
Electronic health record system for sri lankan general practitionersElectronic health record system for sri lankan general practitioners
Electronic health record system for sri lankan general practitioners
 

Recently uploaded

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

Recently uploaded (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

5. variables & data types

  • 1. Variables & Data Types Dr. M H B Ariyaratne https://goo.gl/ytyvLS
  • 2. Variables ● Reserved memory locations to store values ● When we create a variable we reserve some space in memory. ● Based on the datatype of a variable, the operating system allocates memory and decides what can be stored in the reserved memory. ● By assigning different data types to variables, we can store integers, decimals, or characters in these variables
  • 3. Types of Variables Primitive Data Types Reference/Object Data Types
  • 4. Primitive Data Types Predefined by the language Named by a keyword Java - eight primitive data types
  • 5. Naming variables in JAVA ● Variable names are case-sensitive ● An unlimited-length sequence of Unicode letters and digits ● Beginning with a letter, the dollar sign "$", or the underscore character "_" ● White space is not permitted ● Subsequent characters may be letters, digits, dollar signs, or underscore characters. ● Use full words instead of cryptic abbreviations. ● Must not be a keyword or reserved word. ● If only one word, spell that word in all lowercase letters ● If more than one word, capitalize the first letter of each subsequent word. ● If your variable stores a constant value capitalizing every letter and
  • 6. Primitive Data Types - byte ● Byte data type is an 8-bit signed two's complement integer ● Minimum value is -128 (-27) ● Maximum value is 127 (inclusive)(27 -1) ● Default value is 0 ● Byte data type is used to save space in large arrays, mainly in place of integers ● Example: byte a = 100 , byte b = -50
  • 7. Primitive Data Types - short ● 16-bit signed two's complement integer. ● Minimum value is -32,768 (-215) ● Maximum value is 32,767 (inclusive) (215 -1) ● Short data type can also be used to save memory as byte data type. A short is 2 times smaller than an int ● Default value is 0. ● Example: short s = 10000, short r = -20000
  • 8. Primitive Data Type - int ● A 32-bit signed two's complement integer. ● Minimum value is - 2,147,483,648.(-231) ● Maximum value is 2,147,483,647(inclusive).(231 -1) ● int is generally used as the default data type for integral values unless there is a concern about memory ● The default value is 0. ● Example: int a = 100000, int b = -200000
  • 9. Primitive Data Type - long ● A 64-bit signed two's complement integer. ● Minimum value is -9,223,372,036,854,775,808.(-263) ● Maximum value is 9,223,372,036,854,775,807 (inclusive). (263 -1) ● This type is used when a wider range than int is needed. ● Default value is 0L. ● Example: long a = 100000L, int b = -200000L
  • 10. Primitive Data Types - float ● A single-precision 32-bit IEEE 754 floating point. ● Float is mainly used to save memory in large arrays of floating point numbers. ● Default value is 0.0f. ● Example: float f1 = 234.5f
  • 11. Primitive Data Types - double ● A double-precision 64-bit IEEE 754 floating point. ● Generally used as the default data type for decimal values ● Default value is 0.0d. ● Example: double d1 = 123.4
  • 12. Primitive Data Types - boolean ● Represents one bit of information. ● There are only two possible values: true and false. ● This data type is used for simple flags that track true/false conditions. ● Default value is false. ● Example: boolean one = true
  • 13. Primitive Data Types - char ● A single 16-bit Unicode character. ● Minimum value is 'u0000' (or 0). ● Maximum value is 'uffff' (or 65,535 inclusive). ● Char data type is used to store any character. ● Example: char letterA ='A'
  • 14. Reference Data Types We will discuss them under as a separate presentation on Objects and Strings.