SlideShare a Scribd company logo
1 of 16
D ATA T Y P E S
By : Aman Sharma
DATA TYPES IN JAVA
• Data types in Java are classified into
• Primitive types • Non-primitive types
• Primitive types are also known as simple data types
• A primitive type is predefined by the language
• Primitive types are further classified into
• Numeric types
• Non-numeric types
NON-PRIMITIVE DATATYPE
Non-primitive types are also known as reference types
• Non-primitive types are
• Classes
• Interfaces
• Arrays
• Primitive Java data types can be grouped into
• integers
• floating point numbers
• characters
• boolean
INTEGER TYPES
• Java defines four integer types: byte, short, int and long
• All these are signed, positive and negative values
• Java does not support unsigned types
• byte is 8 bit width , short is 16 bit width int is 32 bit width and long is 64 bit width
BYTE TYPE
• The smallest type is byte
• Range from -128 to +128
• Byte variables are declared by use of keyword ‘byte ‘
eg.
byte x, y;
SHORT TYPE
• short is a signed 16 bit type.
• Its range is from -32,768 to +32,767
• It is probably the least used data type in Java
• Keyword used is ‘short’
eg.
short x;
INT TYPE
• The most commonly used integer data type is int
• It has a range of -2,147,483,648 to 2,147,483,647
• Keyword used is ‘int’
eg.
int x;
LONG TYPE
• long is a signed 64 bit type
• Useful where an int type is not large enough to hold the desired value
• The range of large is quite large
• This makes it useful when large, whole numbers are needed
• Keyword used is ‘long’
eg. :
long seconds;
FLOATING POINT TYPES
• floating point numbers are also known as real numbers
• Are used when fractional components are required
• float and double are two kinds of floating point types
• Keywords used are ‘float’ and ‘double’
FLOAT TYPE
• float specify a single precision value that uses 32 bits of storage
• float type is useful when you require fractional component, but does not require a large
degree of precision
eg.
float area
DOUBLE TYPE
• double uses 64 bits of storage
• When you need to maintain accuracy over many iterative calculations or manipulating
large valued numbers double is the best choice
eg. :
double area;
CHARACTER TYPE
• In Java the data type used to store character is char
• char in Java is different from char in C and C++
• Java used Unicode to represent characters
• Unicode was selected because it would help in internationalization of Java as a programming
language
• Java character is 16 bit type.
The range of the characters is 0 to 65,536
BOOLEAN TYPE
• boolean data type is used to represent logical values that can be either true or false
• All relational, conditional and logical operators return boolean values
• It used only one bit of storage
• Keyword used is ‘boolean’
eg;.
boolean flag;
THE SIMPLE DATA TYPES IN JAVA
• In summary Java defines eight simple types of data.
They are
• byte
• short
• int
• long
• char
• float
• double
• boolean
THANK
YOU

More Related Content

What's hot

Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
itft-Decision making and branching in java
itft-Decision making and branching in javaitft-Decision making and branching in java
itft-Decision making and branching in javaAtul Sehdev
 
Datatype in JavaScript
Datatype in JavaScriptDatatype in JavaScript
Datatype in JavaScriptRajat Saxena
 
Java basics and java variables
Java basics and java variablesJava basics and java variables
Java basics and java variablesPushpendra Tyagi
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSaba Ameer
 
Command line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorialCommand line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorialKuntal Bhowmick
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packagesVINOTH R
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 
Introduction to basics of java
Introduction to basics of javaIntroduction to basics of java
Introduction to basics of javavinay arora
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
 
Exception handling and templates
Exception handling and templatesException handling and templates
Exception handling and templatesfarhan amjad
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of ConstructorsDhrumil Panchal
 

What's hot (20)

Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
itft-Decision making and branching in java
itft-Decision making and branching in javaitft-Decision making and branching in java
itft-Decision making and branching in java
 
Datatype in JavaScript
Datatype in JavaScriptDatatype in JavaScript
Datatype in JavaScript
 
Java basics and java variables
Java basics and java variablesJava basics and java variables
Java basics and java variables
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Loops in c
Loops in cLoops in c
Loops in c
 
sql-commands.pdf
sql-commands.pdfsql-commands.pdf
sql-commands.pdf
 
JAVA INTRODUCTION - 1
JAVA INTRODUCTION - 1JAVA INTRODUCTION - 1
JAVA INTRODUCTION - 1
 
07 java variables
07   java variables07   java variables
07 java variables
 
Command line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorialCommand line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorial
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Introduction to basics of java
Introduction to basics of javaIntroduction to basics of java
Introduction to basics of java
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Exception handling and templates
Exception handling and templatesException handling and templates
Exception handling and templates
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Java I/o streams
Java I/o streamsJava I/o streams
Java I/o streams
 
Java String Handling
Java String HandlingJava String Handling
Java String Handling
 

Similar to Data types IN JAVA

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
 
C Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptxC Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptxMurali M
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in CSahithi Naraparaju
 
CONSTANTS, VARIABLES & DATATYPES IN C
CONSTANTS, VARIABLES & DATATYPES IN CCONSTANTS, VARIABLES & DATATYPES IN C
CONSTANTS, VARIABLES & DATATYPES IN CSahithi Naraparaju
 
demo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.pptdemo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.pptFerdieBalang
 
Lecture06-TypesVarsConsts variables data types
Lecture06-TypesVarsConsts variables data typesLecture06-TypesVarsConsts variables data types
Lecture06-TypesVarsConsts variables data typesatifmugheesv
 
Lecture+06-TypesVars.ppt
Lecture+06-TypesVars.pptLecture+06-TypesVars.ppt
Lecture+06-TypesVars.pptKamranAli649587
 
Chapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxChapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxlemonchoos
 
Data Types in C language
Data Types in C languageData Types in C language
Data Types in C languageAbdulKabeer50
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variablesteach4uin
 
PART 1 - Python Tutorial | Variables and Data Types in Python
PART 1 - Python Tutorial | Variables and Data Types in PythonPART 1 - Python Tutorial | Variables and Data Types in Python
PART 1 - Python Tutorial | Variables and Data Types in PythonShivam Mitra
 
introduction to python
 introduction to python introduction to python
introduction to pythonJincy Nelson
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 

Similar to Data types IN JAVA (20)

Data types
Data typesData types
Data types
 
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
 
C Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptxC Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptx
 
Data type
Data typeData type
Data type
 
Variable
VariableVariable
Variable
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
 
CONSTANTS, VARIABLES & DATATYPES IN C
CONSTANTS, VARIABLES & DATATYPES IN CCONSTANTS, VARIABLES & DATATYPES IN C
CONSTANTS, VARIABLES & DATATYPES IN C
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
demo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.pptdemo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.ppt
 
Lecture06-TypesVarsConsts variables data types
Lecture06-TypesVarsConsts variables data typesLecture06-TypesVarsConsts variables data types
Lecture06-TypesVarsConsts variables data types
 
Lecture+06-TypesVars.ppt
Lecture+06-TypesVars.pptLecture+06-TypesVars.ppt
Lecture+06-TypesVars.ppt
 
Chapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptxChapter7-Introduction to Python.pptx
Chapter7-Introduction to Python.pptx
 
Data Types in C language
Data Types in C languageData Types in C language
Data Types in C language
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
 
PART 1 - Python Tutorial | Variables and Data Types in Python
PART 1 - Python Tutorial | Variables and Data Types in PythonPART 1 - Python Tutorial | Variables and Data Types in Python
PART 1 - Python Tutorial | Variables and Data Types in Python
 
introduction to python
 introduction to python introduction to python
introduction to python
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptx
 
C language
C languageC language
C language
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 

More from garishma bhatia

More from garishma bhatia (19)

Peephole optimization techniques
Peephole optimization techniquesPeephole optimization techniques
Peephole optimization techniques
 
Vm migration techniques
Vm migration techniquesVm migration techniques
Vm migration techniques
 
Denial of service
Denial of serviceDenial of service
Denial of service
 
Iot + cloud
Iot + cloudIot + cloud
Iot + cloud
 
WORKFLOW OF THE PROCESS IN SPM
 WORKFLOW OF THE PROCESS IN SPM WORKFLOW OF THE PROCESS IN SPM
WORKFLOW OF THE PROCESS IN SPM
 
MULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULINGMULTILEVEL QUEUE SCHEDULING
MULTILEVEL QUEUE SCHEDULING
 
Constructor overloading & method overloading
Constructor overloading & method overloadingConstructor overloading & method overloading
Constructor overloading & method overloading
 
MULTIPLE ACCESS PROTOCOL COMPUTER NETWORKS
MULTIPLE ACCESS PROTOCOL COMPUTER NETWORKS MULTIPLE ACCESS PROTOCOL COMPUTER NETWORKS
MULTIPLE ACCESS PROTOCOL COMPUTER NETWORKS
 
BLOCKCHAIN TECHNOLOGY
BLOCKCHAIN TECHNOLOGYBLOCKCHAIN TECHNOLOGY
BLOCKCHAIN TECHNOLOGY
 
Knapsack problem
Knapsack problemKnapsack problem
Knapsack problem
 
PRIM'S ALGORITHM
PRIM'S ALGORITHMPRIM'S ALGORITHM
PRIM'S ALGORITHM
 
Data Algorithms And Analysis
Data Algorithms And AnalysisData Algorithms And Analysis
Data Algorithms And Analysis
 
VEHICLE REGISTRATION PROJECT
VEHICLE REGISTRATION PROJECTVEHICLE REGISTRATION PROJECT
VEHICLE REGISTRATION PROJECT
 
WIFI TECH
WIFI TECHWIFI TECH
WIFI TECH
 
MATCHING GRAPH THEORY
MATCHING GRAPH THEORYMATCHING GRAPH THEORY
MATCHING GRAPH THEORY
 
Garishma se
Garishma seGarishma se
Garishma se
 
Garishma xcs
Garishma xcsGarishma xcs
Garishma xcs
 
Garishma maTHS
Garishma maTHSGarishma maTHS
Garishma maTHS
 
Garishma ec
Garishma ecGarishma ec
Garishma ec
 

Recently uploaded

OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 

Recently uploaded (20)

OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 

Data types IN JAVA

  • 1. D ATA T Y P E S By : Aman Sharma
  • 2. DATA TYPES IN JAVA • Data types in Java are classified into • Primitive types • Non-primitive types • Primitive types are also known as simple data types • A primitive type is predefined by the language • Primitive types are further classified into • Numeric types • Non-numeric types
  • 3. NON-PRIMITIVE DATATYPE Non-primitive types are also known as reference types • Non-primitive types are • Classes • Interfaces • Arrays
  • 4. • Primitive Java data types can be grouped into • integers • floating point numbers • characters • boolean
  • 5. INTEGER TYPES • Java defines four integer types: byte, short, int and long • All these are signed, positive and negative values • Java does not support unsigned types • byte is 8 bit width , short is 16 bit width int is 32 bit width and long is 64 bit width
  • 6. BYTE TYPE • The smallest type is byte • Range from -128 to +128 • Byte variables are declared by use of keyword ‘byte ‘ eg. byte x, y;
  • 7. SHORT TYPE • short is a signed 16 bit type. • Its range is from -32,768 to +32,767 • It is probably the least used data type in Java • Keyword used is ‘short’ eg. short x;
  • 8. INT TYPE • The most commonly used integer data type is int • It has a range of -2,147,483,648 to 2,147,483,647 • Keyword used is ‘int’ eg. int x;
  • 9. LONG TYPE • long is a signed 64 bit type • Useful where an int type is not large enough to hold the desired value • The range of large is quite large • This makes it useful when large, whole numbers are needed • Keyword used is ‘long’ eg. : long seconds;
  • 10. FLOATING POINT TYPES • floating point numbers are also known as real numbers • Are used when fractional components are required • float and double are two kinds of floating point types • Keywords used are ‘float’ and ‘double’
  • 11. FLOAT TYPE • float specify a single precision value that uses 32 bits of storage • float type is useful when you require fractional component, but does not require a large degree of precision eg. float area
  • 12. DOUBLE TYPE • double uses 64 bits of storage • When you need to maintain accuracy over many iterative calculations or manipulating large valued numbers double is the best choice eg. : double area;
  • 13. CHARACTER TYPE • In Java the data type used to store character is char • char in Java is different from char in C and C++ • Java used Unicode to represent characters • Unicode was selected because it would help in internationalization of Java as a programming language • Java character is 16 bit type. The range of the characters is 0 to 65,536
  • 14. BOOLEAN TYPE • boolean data type is used to represent logical values that can be either true or false • All relational, conditional and logical operators return boolean values • It used only one bit of storage • Keyword used is ‘boolean’ eg;. boolean flag;
  • 15. THE SIMPLE DATA TYPES IN JAVA • In summary Java defines eight simple types of data. They are • byte • short • int • long • char • float • double • boolean