SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
youtube: Zooming | https://github.com/Soba-Arjun/
Basic Datatypes
• Datatypes: int, String, float, short, byte, long,
double, Boolean.
• Datatypes used to create a variables.
• Variables are reserved memory location to store
values.
• When we create variables, we receive some
space in memory.
youtube: Zooming | https://github.com/Soba-Arjun/
96.6
200
P1713
Moon
name
regno
amountpercentage
Basic Datatypes
• Based on the datatype of variable, the operating
system allocate memory and decides what can
be stored in their memory.
• By assigning different values to variables, we
can store different datatypes.
• 2 datatypes: Primitive, Reference/Object
youtube: Zooming | https://github.com/Soba-Arjun/
96.6
200
P1713
Moon
name
regno
amountpercentage
Basic Datatypes – Primitive Data Types
• Primitive datatypes are predefined by the language and named by a keywords.
• There are 8 primitive datatypes supported by java.
youtube: Zooming | https://github.com/Soba-Arjun/
1. byte
2. short
3. int
4. long
5. float
6. double
7. boolean
8. char
Primitive Data Types ( byte)
• 8 bit signed 2’s complement integer.
youtube: Zooming | https://github.com/Soba-Arjun/
(-128)
(0)
• Used to save space in large array.
• 4 times smaller than int.
byte a = 68;
(127)
byte a = -128;
Primitive Data Types ( short)
• 16 bit signed 2’s complement integer.
youtube: Zooming | https://github.com/Soba-Arjun/
(-32,768)
(0)
(32,767)
• Used to save space in large array.
• 2 times smaller than int.
short a = 1000;short a = -1000;
Primitive Data Types ( int)
• 32 bit signed 2’s complement integer.
youtube: Zooming | https://github.com/Soba-Arjun/
(-2,147,483,648)
(0)
(2,147,483,647)
• Default datatypes for integral values.
• There is a concern about memory.
int a = 1236542;int a = -123648;
Primitive Data Types ( long)
• 64 bit signed 2’s complement integer.
youtube: Zooming | https://github.com/Soba-Arjun/
• This type is used when a wider range than int is need
int a = 10486L;long a = -100L;
L is maximum duration of 32
10486L =
-9,223,372,036,854,775,808 to 0L to -9,223,372,036,854,775,807
Primitive Data Types ( float)
• single-precision 32-bit IEEE 754 floating point.
youtube: Zooming | https://github.com/Soba-Arjun/
• Used to save memory in large arrays of floating point values.
• Never used for precise values such as currency.
float a = 234.5f;0.0f
Primitive Data Types ( double)
• double-precision 32-bit IEEE 754 floating point.
youtube: Zooming | https://github.com/Soba-Arjun/
• generally used as the default data type for decimal values.
• Never used for precise values such as currency.
double a = 234.5;0.0d
Primitive Data Types ( boolean)
• It represents one bit of information.
• 2 possible values: true and false.
• This data type is used for simple flags that
track true/false conditions.
• Default value: false.
youtube: Zooming | https://github.com/Soba-Arjun/
boolean a = true;
asign a=10
asign b=20
a=b //false
asign b=b-a
a=b //true
Primitive Data Types ( char)
• 16 bit Unicode character.
youtube: Zooming | https://github.com/Soba-Arjun/
• Char data type is used to store any character.
char a = ‘A’;‘u0000’
(0)
‘uffff’
(65,535 inclusive)
Basic Datatypes – Reference Data Types
• Reference variables are created using defined constructors of the classes.
• They are used to access objects.
• Class objects and various type of array variables come under reference datatype
• Default value is null.
youtube: Zooming | https://github.com/Soba-Arjun/
Animal a=new Animal();
Animal a=new Animal(0,’asdf’);
Basic Datatypes Notation Character represented
n Newline (0x0a)
r Carriage return (0x0d)
f Formfeed (0x0c)
b Backspace (0x08)
s Space (0x20)
t tab
" Double quote
' Single quote
 backslash
ddd Octal character (ddd)
uxxxx Hexadecimal UNICODE
character (xxxx)
youtube: Zooming | https://github.com/Soba-Arjun/
• Few special escape
sequences for String
and char literals

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Primitive data types
Primitive data typesPrimitive data types
Primitive data types
 
Quick Scala
Quick ScalaQuick Scala
Quick Scala
 
Python Data Types
Python Data TypesPython Data Types
Python Data Types
 
Datatype
DatatypeDatatype
Datatype
 
ITFT - Java
ITFT - JavaITFT - Java
ITFT - Java
 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
 
Numeric Data types in Python
Numeric Data types in PythonNumeric Data types in Python
Numeric Data types in Python
 
Classroom Object Oriented Language (COOL)
Classroom Object Oriented Language (COOL)Classroom Object Oriented Language (COOL)
Classroom Object Oriented Language (COOL)
 
Csc240 -lecture_4
Csc240  -lecture_4Csc240  -lecture_4
Csc240 -lecture_4
 
C# Basics
C# BasicsC# Basics
C# Basics
 
Data types in C
Data types in CData types in C
Data types in C
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
What are variables and keywords in c++
What are variables and keywords in c++What are variables and keywords in c++
What are variables and keywords in c++
 
Java session3
Java session3Java session3
Java session3
 
Types in .net
Types in .netTypes in .net
Types in .net
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data type
 
5variables in c#
5variables in c#5variables in c#
5variables in c#
 
C#
C#C#
C#
 

Ähnlich wie Java basic datatypes

Programming Language
Programming  LanguageProgramming  Language
Programming Language
Adeel Hamid
 
2014 manchester-reproducibility
2014 manchester-reproducibility2014 manchester-reproducibility
2014 manchester-reproducibility
c.titus.brown
 
(Julien le dem) parquet
(Julien le dem)   parquet(Julien le dem)   parquet
(Julien le dem) parquet
NAVER D2
 
CJUS 703Biblical Worldview of Corrections Assignment Instruction
CJUS 703Biblical Worldview of Corrections Assignment InstructionCJUS 703Biblical Worldview of Corrections Assignment Instruction
CJUS 703Biblical Worldview of Corrections Assignment Instruction
VinaOconner450
 

Ähnlich wie Java basic datatypes (20)

Java basic datatypes
Java basic datatypesJava basic datatypes
Java basic datatypes
 
Core java
Core javaCore java
Core java
 
Core java
Core javaCore java
Core java
 
Programming Language
Programming  LanguageProgramming  Language
Programming Language
 
SNIA : Swift Object Storage adding EC (Erasure Code)
SNIA : Swift Object Storage adding EC (Erasure Code)SNIA : Swift Object Storage adding EC (Erasure Code)
SNIA : Swift Object Storage adding EC (Erasure Code)
 
Data Evolution on HBase with Kiji
Data Evolution on HBase with KijiData Evolution on HBase with Kiji
Data Evolution on HBase with Kiji
 
Data Evolution on HBase (with Kiji)
Data Evolution on HBase (with Kiji)Data Evolution on HBase (with Kiji)
Data Evolution on HBase (with Kiji)
 
2014 manchester-reproducibility
2014 manchester-reproducibility2014 manchester-reproducibility
2014 manchester-reproducibility
 
From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...From SaltStack to Puppet and beyond...
From SaltStack to Puppet and beyond...
 
Every Solution is Wrong: Normalizing Ambiguous, Broken, and Pants-on-Head Cra...
Every Solution is Wrong: Normalizing Ambiguous, Broken, and Pants-on-Head Cra...Every Solution is Wrong: Normalizing Ambiguous, Broken, and Pants-on-Head Cra...
Every Solution is Wrong: Normalizing Ambiguous, Broken, and Pants-on-Head Cra...
 
(Julien le dem) parquet
(Julien le dem)   parquet(Julien le dem)   parquet
(Julien le dem) parquet
 
Java platform
Java platformJava platform
Java platform
 
Python-Yesterday Today Tomorrow(What's new?)
Python-Yesterday Today Tomorrow(What's new?)Python-Yesterday Today Tomorrow(What's new?)
Python-Yesterday Today Tomorrow(What's new?)
 
Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"Игорь Фесенко "Direction of C# as a High-Performance Language"
Игорь Фесенко "Direction of C# as a High-Performance Language"
 
CJUS 703Biblical Worldview of Corrections Assignment Instruction
CJUS 703Biblical Worldview of Corrections Assignment InstructionCJUS 703Biblical Worldview of Corrections Assignment Instruction
CJUS 703Biblical Worldview of Corrections Assignment Instruction
 
Automation using Puppet 3
Automation using Puppet 3 Automation using Puppet 3
Automation using Puppet 3
 
SFDC Introduction to Apex
SFDC Introduction to ApexSFDC Introduction to Apex
SFDC Introduction to Apex
 
How to Make OpenStack Heat Better based on Our One Year Production Journey
How to Make OpenStack Heat Better based on Our One Year Production JourneyHow to Make OpenStack Heat Better based on Our One Year Production Journey
How to Make OpenStack Heat Better based on Our One Year Production Journey
 
Search at Twitter: Presented by Michael Busch, Twitter
Search at Twitter: Presented by Michael Busch, TwitterSearch at Twitter: Presented by Michael Busch, Twitter
Search at Twitter: Presented by Michael Busch, Twitter
 
Python ml
Python mlPython ml
Python ml
 

Mehr von Soba Arjun

Mehr von Soba Arjun (20)

Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
Java modifiers
Java modifiersJava modifiers
Java modifiers
 
Java variable types
Java variable typesJava variable types
Java variable types
 
Dbms interview questions
Dbms interview questionsDbms interview questions
Dbms interview questions
 
C interview questions
C interview questionsC interview questions
C interview questions
 
Technical interview questions
Technical interview questionsTechnical interview questions
Technical interview questions
 
Php interview questions with answer
Php interview questions with answerPhp interview questions with answer
Php interview questions with answer
 
Computer Memory Types - Primary Memory - Secondary Memory
Computer Memory Types - Primary Memory - Secondary MemoryComputer Memory Types - Primary Memory - Secondary Memory
Computer Memory Types - Primary Memory - Secondary Memory
 
Birds sanctuaries
Birds sanctuariesBirds sanctuaries
Birds sanctuaries
 
Important operating systems
Important operating systemsImportant operating systems
Important operating systems
 
Important branches of science
Important branches of scienceImportant branches of science
Important branches of science
 
Important file extensions
Important file extensionsImportant file extensions
Important file extensions
 
Java Abstraction
Java AbstractionJava Abstraction
Java Abstraction
 
Java Polymorphism
Java PolymorphismJava Polymorphism
Java Polymorphism
 
Java Overriding
Java OverridingJava Overriding
Java Overriding
 
Java Inner Classes
Java Inner ClassesJava Inner Classes
Java Inner Classes
 
java Exception
java Exceptionjava Exception
java Exception
 
Java Methods
Java MethodsJava Methods
Java Methods
 
java Inheritance
java Inheritancejava Inheritance
java Inheritance
 
Major tribes of india
Major tribes of indiaMajor tribes of india
Major tribes of india
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Java basic datatypes

  • 1. youtube: Zooming | https://github.com/Soba-Arjun/
  • 2. Basic Datatypes • Datatypes: int, String, float, short, byte, long, double, Boolean. • Datatypes used to create a variables. • Variables are reserved memory location to store values. • When we create variables, we receive some space in memory. youtube: Zooming | https://github.com/Soba-Arjun/ 96.6 200 P1713 Moon name regno amountpercentage
  • 3. Basic Datatypes • Based on the datatype of variable, the operating system allocate memory and decides what can be stored in their memory. • By assigning different values to variables, we can store different datatypes. • 2 datatypes: Primitive, Reference/Object youtube: Zooming | https://github.com/Soba-Arjun/ 96.6 200 P1713 Moon name regno amountpercentage
  • 4. Basic Datatypes – Primitive Data Types • Primitive datatypes are predefined by the language and named by a keywords. • There are 8 primitive datatypes supported by java. youtube: Zooming | https://github.com/Soba-Arjun/ 1. byte 2. short 3. int 4. long 5. float 6. double 7. boolean 8. char
  • 5. Primitive Data Types ( byte) • 8 bit signed 2’s complement integer. youtube: Zooming | https://github.com/Soba-Arjun/ (-128) (0) • Used to save space in large array. • 4 times smaller than int. byte a = 68; (127) byte a = -128;
  • 6. Primitive Data Types ( short) • 16 bit signed 2’s complement integer. youtube: Zooming | https://github.com/Soba-Arjun/ (-32,768) (0) (32,767) • Used to save space in large array. • 2 times smaller than int. short a = 1000;short a = -1000;
  • 7. Primitive Data Types ( int) • 32 bit signed 2’s complement integer. youtube: Zooming | https://github.com/Soba-Arjun/ (-2,147,483,648) (0) (2,147,483,647) • Default datatypes for integral values. • There is a concern about memory. int a = 1236542;int a = -123648;
  • 8. Primitive Data Types ( long) • 64 bit signed 2’s complement integer. youtube: Zooming | https://github.com/Soba-Arjun/ • This type is used when a wider range than int is need int a = 10486L;long a = -100L; L is maximum duration of 32 10486L = -9,223,372,036,854,775,808 to 0L to -9,223,372,036,854,775,807
  • 9. Primitive Data Types ( float) • single-precision 32-bit IEEE 754 floating point. youtube: Zooming | https://github.com/Soba-Arjun/ • Used to save memory in large arrays of floating point values. • Never used for precise values such as currency. float a = 234.5f;0.0f
  • 10. Primitive Data Types ( double) • double-precision 32-bit IEEE 754 floating point. youtube: Zooming | https://github.com/Soba-Arjun/ • generally used as the default data type for decimal values. • Never used for precise values such as currency. double a = 234.5;0.0d
  • 11. Primitive Data Types ( boolean) • It represents one bit of information. • 2 possible values: true and false. • This data type is used for simple flags that track true/false conditions. • Default value: false. youtube: Zooming | https://github.com/Soba-Arjun/ boolean a = true; asign a=10 asign b=20 a=b //false asign b=b-a a=b //true
  • 12. Primitive Data Types ( char) • 16 bit Unicode character. youtube: Zooming | https://github.com/Soba-Arjun/ • Char data type is used to store any character. char a = ‘A’;‘u0000’ (0) ‘uffff’ (65,535 inclusive)
  • 13. Basic Datatypes – Reference Data Types • Reference variables are created using defined constructors of the classes. • They are used to access objects. • Class objects and various type of array variables come under reference datatype • Default value is null. youtube: Zooming | https://github.com/Soba-Arjun/ Animal a=new Animal(); Animal a=new Animal(0,’asdf’);
  • 14. Basic Datatypes Notation Character represented n Newline (0x0a) r Carriage return (0x0d) f Formfeed (0x0c) b Backspace (0x08) s Space (0x20) t tab " Double quote ' Single quote backslash ddd Octal character (ddd) uxxxx Hexadecimal UNICODE character (xxxx) youtube: Zooming | https://github.com/Soba-Arjun/ • Few special escape sequences for String and char literals