SlideShare a Scribd company logo
• Java is not pure object oriented.
• Any language which makes use of primitive
type of data such languages are not object
oriented.
• Few purely object oriented languages are
Ex: Scala, Smalltalk, Eiffel ..etc
• The primitive data types are not objects, they
do not belong to any class.
• Sometimes, it is required to convert data types
into objects in Java language.
• A data type can be converted into an object and
then used with the help of Wrapper Classes.
• A wrapper class wraps (encloses) around
a data type and gives it an object
appearance.
• Wherever, the data type is required as an
object, Wrapper class object can be used.
• Wrapper classes include methods to
unwrap the object and give back the data
type.
• It can be compared with a chocolate. The manufacturer
wraps the chocolate with some foil or paper to prevent
from pollution. The user takes the chocolate, removes
and throws the wrapper and eats it.
To wrap (or to convert) each primitive data type, there comes a
wrapper class. Eight wrapper classes exist in java.lang package that
represent 8 data types. Following list gives.
• All wrapper classes are final classes.
• All Wrapper classes implements comparable type.
• All wrapper classes overrides 3 object class methods
1.toString()
2.hashCode()
3.equals(Object obj)
Conversion of primitive data to object type is known as Boxing.
EX: int k = 100;
Integer it1 = new Integer(k);
double d = 3.3;
Double dt2= new Double(d);
Conversion of Object type of data to Primitive type is called as
Un-Boxing.
EX: int m = it1.intValue();
System.out.println(m); // prints 100
double n = dt2.doubleValue();
System.out.println(n); // prints 3.3
Boxing and Un-Boxing Can be done implicitly by compiler, it is
known as Auto Boxing and Auto Un-Boxing.
Integer a1=30; Auto Boxing
int l= a1; Auto Un-Boxing
Wrapper Classes In Collection FrameWorks
• Wrapper Classes are used in collection framework.
• In Collection we can add only Object type of data.
• If primitive data added in Collection Framework then auto boxing and
auto un-boxing both happens Implicitly.
Ex: ArrayList a1 = new ArrayList();
a1.add(12);
a1.add(2356);
a1.add(4.5);
• Here First auto boxing happens and then up-casting to Object class
happens.
Parsing Technique
• Conversion of String type of data to Number format is called as Parsing
• For Parsing we make use of parseX() methods which are present in Wrapper
classes.
Ex:
String str = “1234”;
int i = Integer.parseInt(str);
System.out.println(i); // 1234
• Parsing has to be done carefully, else we may get Exception.
• In previous example if String value is “1234g” ,in this case during parsing the
value doesn’t match with Integer hence we get NumberFormatException.

More Related Content

What's hot

Java constructors
Java constructorsJava constructors
Java constructors
QUONTRASOLUTIONS
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
Ravi_Kant_Sahu
 
Java Strings
Java StringsJava Strings
Java Strings
RaBiya Chaudhry
 
Vectors in Java
Vectors in JavaVectors in Java
Vectors in Java
Abhilash Nair
 
Java String
Java StringJava String
Java String
Java2Blog
 
Autoboxing and unboxing
Autoboxing and unboxingAutoboxing and unboxing
Autoboxing and unboxing
Geetha Manohar
 
This keyword and final keyword
This keyword and final  keywordThis keyword and final  keyword
This keyword and final keyword
kinjalbirare
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
kumar gaurav
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
babak danyal
 
Packages in java
Packages in javaPackages in java
Packages in java
Kavitha713564
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
SIVASHANKARIRAJAN
 
Packages in java
Packages in javaPackages in java
Packages in java
Abhishek Khune
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
SSN College of Engineering, Kalavakkam
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
Scott Leberknight
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
Spotle.ai
 
Standard template library
Standard template libraryStandard template library
Standard template library
Sukriti Singh
 
Classes, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with JavaClasses, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with Java
Radhika Talaviya
 
Java Collections
Java  Collections Java  Collections
Wrapper classes
Wrapper classes Wrapper classes
Constructor overloading & method overloading
Constructor overloading & method overloadingConstructor overloading & method overloading
Constructor overloading & method overloading
garishma bhatia
 

What's hot (20)

Java constructors
Java constructorsJava constructors
Java constructors
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
Java Strings
Java StringsJava Strings
Java Strings
 
Vectors in Java
Vectors in JavaVectors in Java
Vectors in Java
 
Java String
Java StringJava String
Java String
 
Autoboxing and unboxing
Autoboxing and unboxingAutoboxing and unboxing
Autoboxing and unboxing
 
This keyword and final keyword
This keyword and final  keywordThis keyword and final  keyword
This keyword and final keyword
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Java IO Package and Streams
Java IO Package and StreamsJava IO Package and Streams
Java IO Package and Streams
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Packages in java
Packages in javaPackages in java
Packages in java
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Standard template library
Standard template libraryStandard template library
Standard template library
 
Classes, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with JavaClasses, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with Java
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Wrapper classes
Wrapper classes Wrapper classes
Wrapper classes
 
Constructor overloading & method overloading
Constructor overloading & method overloadingConstructor overloading & method overloading
Constructor overloading & method overloading
 

Viewers also liked

Partnering with communities in Colorado
Partnering with communities in ColoradoPartnering with communities in Colorado
Partnering with communities in Colorado
Donald Nease
 
Ays Summer Meet the Stars
Ays Summer Meet the StarsAys Summer Meet the Stars
Ays Summer Meet the Stars
AysSummer
 
Business health check business infoload 2016
Business health check   business infoload 2016Business health check   business infoload 2016
Business health check business infoload 2016
Infoload
 
Are you keen to know about upcoming trends in Live Event Industry
Are you keen to know about upcoming trends in Live Event IndustryAre you keen to know about upcoming trends in Live Event Industry
Are you keen to know about upcoming trends in Live Event Industry
Priyadarshani Jain
 
Resource wrappers in C++
Resource wrappers in C++Resource wrappers in C++
Resource wrappers in C++
Ilio Catallo
 
C++ 11 range-based for loop
C++ 11   range-based for loopC++ 11   range-based for loop
C++ 11 range-based for loop
mohamed sikander
 

Viewers also liked (6)

Partnering with communities in Colorado
Partnering with communities in ColoradoPartnering with communities in Colorado
Partnering with communities in Colorado
 
Ays Summer Meet the Stars
Ays Summer Meet the StarsAys Summer Meet the Stars
Ays Summer Meet the Stars
 
Business health check business infoload 2016
Business health check   business infoload 2016Business health check   business infoload 2016
Business health check business infoload 2016
 
Are you keen to know about upcoming trends in Live Event Industry
Are you keen to know about upcoming trends in Live Event IndustryAre you keen to know about upcoming trends in Live Event Industry
Are you keen to know about upcoming trends in Live Event Industry
 
Resource wrappers in C++
Resource wrappers in C++Resource wrappers in C++
Resource wrappers in C++
 
C++ 11 range-based for loop
C++ 11   range-based for loopC++ 11   range-based for loop
C++ 11 range-based for loop
 

Similar to JSpiders - Wrapper classes

L9 wrapper classes
L9 wrapper classesL9 wrapper classes
L9 wrapper classes
teach4uin
 
Java tutorial part 3
Java tutorial part 3Java tutorial part 3
Java tutorial part 3
Mumbai Academisc
 
Java Unit 2(Part 1)
Java Unit 2(Part 1)Java Unit 2(Part 1)
Java Unit 2(Part 1)
SURBHI SAROHA
 
C# Generics
C# GenericsC# Generics
C# Generics
Praveen Kumar
 
Ch 2 Library Classes.pdf
Ch 2 Library Classes.pdfCh 2 Library Classes.pdf
Ch 2 Library Classes.pdf
KavitaHegde4
 
Ch 2 Library Classes.pptx
Ch 2 Library Classes.pptxCh 2 Library Classes.pptx
Ch 2 Library Classes.pptx
KavitaHegde4
 
static MEMBER IN OOPS PROGRAMING LANGUAGE.pptx
static MEMBER IN OOPS PROGRAMING LANGUAGE.pptxstatic MEMBER IN OOPS PROGRAMING LANGUAGE.pptx
static MEMBER IN OOPS PROGRAMING LANGUAGE.pptx
urvashipundir04
 
static members in object oriented program.pptx
static members in object oriented program.pptxstatic members in object oriented program.pptx
static members in object oriented program.pptx
urvashipundir04
 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptx
Epsiba1
 
Object Oriented Programming.pptx
Object Oriented Programming.pptxObject Oriented Programming.pptx
Object Oriented Programming.pptx
SAICHARANREDDYN
 
Java Tutorial Lab 2
Java Tutorial Lab 2Java Tutorial Lab 2
Java Tutorial Lab 2
Berk Soysal
 
Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
YakaviBalakrishnan
 
02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt
Yonas D. Ebren
 
Java Day-4
Java Day-4Java Day-4
Java Day-4
People Strategists
 
oopm 2.pdf
oopm 2.pdfoopm 2.pdf
oopm 2.pdf
jayeshsoni49
 
C++ training
C++ training C++ training
C++ training
PL Sharma
 
Lecture 5.pptx
Lecture 5.pptxLecture 5.pptx
Lecture 5.pptx
AshutoshTrivedi30
 
Md02 - Getting Started part-2
Md02 - Getting Started part-2Md02 - Getting Started part-2
Md02 - Getting Started part-2
Rakesh Madugula
 
unit 2 java.pptx
unit 2 java.pptxunit 2 java.pptx
unit 2 java.pptx
AshokKumar587867
 
Java For Automation
Java   For AutomationJava   For Automation
Java For Automation
Abhijeet Dubey
 

Similar to JSpiders - Wrapper classes (20)

L9 wrapper classes
L9 wrapper classesL9 wrapper classes
L9 wrapper classes
 
Java tutorial part 3
Java tutorial part 3Java tutorial part 3
Java tutorial part 3
 
Java Unit 2(Part 1)
Java Unit 2(Part 1)Java Unit 2(Part 1)
Java Unit 2(Part 1)
 
C# Generics
C# GenericsC# Generics
C# Generics
 
Ch 2 Library Classes.pdf
Ch 2 Library Classes.pdfCh 2 Library Classes.pdf
Ch 2 Library Classes.pdf
 
Ch 2 Library Classes.pptx
Ch 2 Library Classes.pptxCh 2 Library Classes.pptx
Ch 2 Library Classes.pptx
 
static MEMBER IN OOPS PROGRAMING LANGUAGE.pptx
static MEMBER IN OOPS PROGRAMING LANGUAGE.pptxstatic MEMBER IN OOPS PROGRAMING LANGUAGE.pptx
static MEMBER IN OOPS PROGRAMING LANGUAGE.pptx
 
static members in object oriented program.pptx
static members in object oriented program.pptxstatic members in object oriented program.pptx
static members in object oriented program.pptx
 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptx
 
Object Oriented Programming.pptx
Object Oriented Programming.pptxObject Oriented Programming.pptx
Object Oriented Programming.pptx
 
Java Tutorial Lab 2
Java Tutorial Lab 2Java Tutorial Lab 2
Java Tutorial Lab 2
 
Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
 
02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt02._Object-Oriented_Programming_Concepts.ppt
02._Object-Oriented_Programming_Concepts.ppt
 
Java Day-4
Java Day-4Java Day-4
Java Day-4
 
oopm 2.pdf
oopm 2.pdfoopm 2.pdf
oopm 2.pdf
 
C++ training
C++ training C++ training
C++ training
 
Lecture 5.pptx
Lecture 5.pptxLecture 5.pptx
Lecture 5.pptx
 
Md02 - Getting Started part-2
Md02 - Getting Started part-2Md02 - Getting Started part-2
Md02 - Getting Started part-2
 
unit 2 java.pptx
unit 2 java.pptxunit 2 java.pptx
unit 2 java.pptx
 
Java For Automation
Java   For AutomationJava   For Automation
Java For Automation
 

More from JSpiders Basavanagudi

Profit n loss assignments
Profit n loss assignmentsProfit n loss assignments
Profit n loss assignments
JSpiders Basavanagudi
 
JSpiders_Percentages assignments 1
JSpiders_Percentages assignments 1JSpiders_Percentages assignments 1
JSpiders_Percentages assignments 1
JSpiders Basavanagudi
 
JSpiders-Ratios assignments
JSpiders-Ratios assignmentsJSpiders-Ratios assignments
JSpiders-Ratios assignments
JSpiders Basavanagudi
 
JSpiders Numbers assignment 1
JSpiders Numbers assignment 1JSpiders Numbers assignment 1
JSpiders Numbers assignment 1
JSpiders Basavanagudi
 
JSpiders BTR Uco bank clericalcadreexam2008e
JSpiders BTR Uco bank clericalcadreexam2008eJSpiders BTR Uco bank clericalcadreexam2008e
JSpiders BTR Uco bank clericalcadreexam2008e
JSpiders Basavanagudi
 
JSpiders BTR Oriental bank of commerce clerical sample question paper all ...
JSpiders BTR  Oriental bank of commerce clerical sample question paper   all ...JSpiders BTR  Oriental bank of commerce clerical sample question paper   all ...
JSpiders BTR Oriental bank of commerce clerical sample question paper all ...
JSpiders Basavanagudi
 
JSpiders BTR Cw emocktest
JSpiders BTR Cw emocktestJSpiders BTR Cw emocktest
JSpiders BTR Cw emocktest
JSpiders Basavanagudi
 
JSPiders Common written exam (cwe) for various public sector banks in india s...
JSPiders Common written exam (cwe) for various public sector banks in india s...JSPiders Common written exam (cwe) for various public sector banks in india s...
JSPiders Common written exam (cwe) for various public sector banks in india s...
JSpiders Basavanagudi
 
Aptitude
Aptitude Aptitude

More from JSpiders Basavanagudi (9)

Profit n loss assignments
Profit n loss assignmentsProfit n loss assignments
Profit n loss assignments
 
JSpiders_Percentages assignments 1
JSpiders_Percentages assignments 1JSpiders_Percentages assignments 1
JSpiders_Percentages assignments 1
 
JSpiders-Ratios assignments
JSpiders-Ratios assignmentsJSpiders-Ratios assignments
JSpiders-Ratios assignments
 
JSpiders Numbers assignment 1
JSpiders Numbers assignment 1JSpiders Numbers assignment 1
JSpiders Numbers assignment 1
 
JSpiders BTR Uco bank clericalcadreexam2008e
JSpiders BTR Uco bank clericalcadreexam2008eJSpiders BTR Uco bank clericalcadreexam2008e
JSpiders BTR Uco bank clericalcadreexam2008e
 
JSpiders BTR Oriental bank of commerce clerical sample question paper all ...
JSpiders BTR  Oriental bank of commerce clerical sample question paper   all ...JSpiders BTR  Oriental bank of commerce clerical sample question paper   all ...
JSpiders BTR Oriental bank of commerce clerical sample question paper all ...
 
JSpiders BTR Cw emocktest
JSpiders BTR Cw emocktestJSpiders BTR Cw emocktest
JSpiders BTR Cw emocktest
 
JSPiders Common written exam (cwe) for various public sector banks in india s...
JSPiders Common written exam (cwe) for various public sector banks in india s...JSPiders Common written exam (cwe) for various public sector banks in india s...
JSPiders Common written exam (cwe) for various public sector banks in india s...
 
Aptitude
Aptitude Aptitude
Aptitude
 

Recently uploaded

A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
aymanquadri279
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
Ayan Halder
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 

Recently uploaded (20)

A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
What is Master Data Management by PiLog Group
What is Master Data Management by PiLog GroupWhat is Master Data Management by PiLog Group
What is Master Data Management by PiLog Group
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Requirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional SafetyRequirement Traceability in Xen Functional Safety
Requirement Traceability in Xen Functional Safety
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 

JSpiders - Wrapper classes

  • 1.
  • 2. • Java is not pure object oriented. • Any language which makes use of primitive type of data such languages are not object oriented. • Few purely object oriented languages are Ex: Scala, Smalltalk, Eiffel ..etc • The primitive data types are not objects, they do not belong to any class. • Sometimes, it is required to convert data types into objects in Java language. • A data type can be converted into an object and then used with the help of Wrapper Classes.
  • 3. • A wrapper class wraps (encloses) around a data type and gives it an object appearance. • Wherever, the data type is required as an object, Wrapper class object can be used. • Wrapper classes include methods to unwrap the object and give back the data type.
  • 4. • It can be compared with a chocolate. The manufacturer wraps the chocolate with some foil or paper to prevent from pollution. The user takes the chocolate, removes and throws the wrapper and eats it.
  • 5. To wrap (or to convert) each primitive data type, there comes a wrapper class. Eight wrapper classes exist in java.lang package that represent 8 data types. Following list gives.
  • 6.
  • 7. • All wrapper classes are final classes. • All Wrapper classes implements comparable type. • All wrapper classes overrides 3 object class methods 1.toString() 2.hashCode() 3.equals(Object obj)
  • 8. Conversion of primitive data to object type is known as Boxing. EX: int k = 100; Integer it1 = new Integer(k); double d = 3.3; Double dt2= new Double(d); Conversion of Object type of data to Primitive type is called as Un-Boxing. EX: int m = it1.intValue(); System.out.println(m); // prints 100 double n = dt2.doubleValue(); System.out.println(n); // prints 3.3
  • 9. Boxing and Un-Boxing Can be done implicitly by compiler, it is known as Auto Boxing and Auto Un-Boxing. Integer a1=30; Auto Boxing int l= a1; Auto Un-Boxing
  • 10. Wrapper Classes In Collection FrameWorks • Wrapper Classes are used in collection framework. • In Collection we can add only Object type of data. • If primitive data added in Collection Framework then auto boxing and auto un-boxing both happens Implicitly. Ex: ArrayList a1 = new ArrayList(); a1.add(12); a1.add(2356); a1.add(4.5); • Here First auto boxing happens and then up-casting to Object class happens.
  • 11. Parsing Technique • Conversion of String type of data to Number format is called as Parsing • For Parsing we make use of parseX() methods which are present in Wrapper classes. Ex: String str = “1234”; int i = Integer.parseInt(str); System.out.println(i); // 1234 • Parsing has to be done carefully, else we may get Exception. • In previous example if String value is “1234g” ,in this case during parsing the value doesn’t match with Integer hence we get NumberFormatException.