SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Downloaden Sie, um offline zu lesen
INFORMATION TECHNOLOGY
PROJECT REPORT
JAVA PROGRAMMING
TOPIC
Wrapper class and
Nesting Method
SUBMITTED BY
PINKLE MAKHIJANI
BCA – IInd
Year
Dezyne E’cole College
www.dezyneecole.com
R
Project Report
On
Java Programming
At
Dezyne E’cole College
Ajmer
Submitted to
Dezyne E’cole College
Towards the
Partial Fulfillment on
Bachelors of Computer Application
By
Pinkle Makhijani
Dezyne E’cole College
106/10,Civil Lines,Ajmer
Tel:-0145-2624679
www.dezyneecole.com
2016-17
R
Acknowledgement
I Pinkle Makhijani, Student Of Dezyne E’cole College , Am Extremely
Grateful To Each And Every Individual Who Has Contributed In Successful
Completion Of My Project. I Express My Gratitude Towards Dezyne
E’cole College For Their Guidance And Constant Supervision As Well As
For Providing The Necessary Information And Support Regarding The
Completion Of Project.
Thank You
Synopsis
This Project Is A Minor Project Made, Based On The Theoretical Concepts
Of Java. This Project Has Made Our Basic Concepts On Java Strong.
Wrapper Classes:-
As pointed out earlier,vectors cannot handel primitive datatypes like int, float, char and
double.Primitive data types may be converted into object types by using the wrapper classes
contained in the java.lang package.Following shows the simple data types and their
correspondence Wrapper class types.
Wrapper Classes For Converting Types
Simple Type Wrapper Class
Boolean Boolean
Char Character
Double Double
Float Float
Int Int
Long Long
The wrapper classeshave a member of unique methodsby handling primitive data types and
objects. They are listed in the following tables.
Converting Primitive Numbers to Object Numbers Using Constructor Method
Constructor Calling Conversion Action
Integer IntVal=new Integer(i); Primitive integer to Integer object
Float FloatVal=new Float(f); Primitive float to Float object
Double DoubleVal=new Double(d); Primitive double to Double object
Long LongVal=new Long(l); Primitive long to Long object
Converting Object Numbers to Primitive Numbers Using typeValue() Method
Method Calling Conversion Action
int i=IntVal.intValue(); Object to Primitive integer
float f=FloatVal.floatValue(); Object to Primitive float
long l=LongVal.longValu(); Object to Primitive long
Double d=Double.val.doubleValue(); Object to Primitive double
Converting Numbers to Strings Using toString() Method
Method Calling Conversion Action
str=Integer.toString(i); Primitive integer to string
str=Float.toString(f); Primitive float to string
str=Double.toString(d); Primitive double to string
str=Long.toString(l); Primitive long to string
Converting String Objects to Numeric Objects Using the Static Method ValueOf()
Method Calling Conversion Action
DoubleVal=Double.ValueOf(str); Converts string to Double Object
FloatVal=Float.ValueOf(str); Converts string to Float Object
IntVal=Integer.ValueOf(str); Converts string to Integer Object
LongVal=Long.ValueOf(str); Converts string to Long Object
Converting Numeric String to Primitive Numbers Using Parsing Methods
Method Calling Conversion Action
int i=Integer.parseInt(str); Converts string to primitive integer
long i=Long.parseInt(str); Converts string to primitive long
Converting Primitive Numbers to Object Numbers
Converting Object Numbers to Primitive Numbers
Converting Number to String
Converting String Object to Numeric Object
Converting Numeric String to Primitive Numbers
Autoboxing and Unboxing:-
The autoboxing and unboxing feature,introduced in J2SE 5.0, facilitates the process of handling
primitive data types in collections. We can use this feature to convert primitive data types to
wrapper class types automatically. The compiler generates a code implicitly to convert primitive
type to the corresponding wrapper class type and vice-versa. For example, consider the following
statements.
Double d=98.42;
Double dbl=d.doubleValue();
Using the autoboxing and unboxing feature, we can rewrite the above code as:
Double d=98.42;
Double dbl=d;
How, the Java compiler provides restrictions to perform the following conversions:
 Convert from nul;l type to any primitive type.
 Convert to the null type other than the identify conversion.
 Convert from any class type C to any array type if C is not object.
Vector without using Autoboxing and Unboxing
Vector with using Autoboxing and Unboxing
Nesting of Methods:-
We discussed earlier that a method of a class can be called only by an object of that class using
the dot operator. However,there is an exception to this. A method can be called by using only its
name by another method of the same class. This is known as nesting of methods.
Program illustrates the nesting of methods inside a class. The class Nesting defines one
constructor and two methods, namely largest() and display(). The method display() calls the
method largest() to determine the largest of the two numbers and then displays the result.
Example of Nesting of Methods
Another Example of Nesting of Methods
A method can call any number of methods. It is also possible for a called method to call another
method. That is, method1 may call method 2, which in turn may call method3.
THANK YOU

Weitere Àhnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Ravi Sharma,BCA 2nd Year
Ravi Sharma,BCA 2nd YearRavi Sharma,BCA 2nd Year
Ravi Sharma,BCA 2nd Year
 
Kajal Gaharwal,BCA 2nd Year
Kajal Gaharwal,BCA 2nd YearKajal Gaharwal,BCA 2nd Year
Kajal Gaharwal,BCA 2nd Year
 
Kaushal Soni,BCA,2nd Year
Kaushal Soni,BCA,2nd YearKaushal Soni,BCA,2nd Year
Kaushal Soni,BCA,2nd Year
 
Rakesh Bijawat , BCA Third Year
Rakesh Bijawat , BCA Third YearRakesh Bijawat , BCA Third Year
Rakesh Bijawat , BCA Third Year
 
Rakesh Bijawat, BCA 2nd Year
Rakesh Bijawat, BCA 2nd YearRakesh Bijawat, BCA 2nd Year
Rakesh Bijawat, BCA 2nd Year
 
Shivani Chouhan ,BCA ,2nd Year
Shivani Chouhan ,BCA ,2nd YearShivani Chouhan ,BCA ,2nd Year
Shivani Chouhan ,BCA ,2nd Year
 
Amit Kumar Yadav ,BCA
Amit Kumar Yadav ,BCAAmit Kumar Yadav ,BCA
Amit Kumar Yadav ,BCA
 
Ram Prasad ,BCA 2nd Year
Ram Prasad ,BCA 2nd YearRam Prasad ,BCA 2nd Year
Ram Prasad ,BCA 2nd Year
 
Pooja Sharma ,BCA 2nd Year
Pooja Sharma ,BCA 2nd YearPooja Sharma ,BCA 2nd Year
Pooja Sharma ,BCA 2nd Year
 
Farhaan Ahmed, BCA 2nd Year
Farhaan Ahmed, BCA 2nd YearFarhaan Ahmed, BCA 2nd Year
Farhaan Ahmed, BCA 2nd Year
 
Yashika Soni, BCA 2nd Year
Yashika Soni, BCA 2nd YearYashika Soni, BCA 2nd Year
Yashika Soni, BCA 2nd Year
 
Daksh Sharma ,BCA 2nd Year
Daksh  Sharma ,BCA 2nd YearDaksh  Sharma ,BCA 2nd Year
Daksh Sharma ,BCA 2nd Year
 
Rahul Saini, BCA 2nd Year
Rahul Saini, BCA 2nd YearRahul Saini, BCA 2nd Year
Rahul Saini, BCA 2nd Year
 
Shaikh Mohammad Usman Haider ,BCA 2nd Year
Shaikh Mohammad Usman Haider ,BCA 2nd Year Shaikh Mohammad Usman Haider ,BCA 2nd Year
Shaikh Mohammad Usman Haider ,BCA 2nd Year
 
Deepak Soni,BCA 2nd Year
Deepak Soni,BCA 2nd YearDeepak Soni,BCA 2nd Year
Deepak Soni,BCA 2nd Year
 
Harendra Singh Rawat,BCA 2nd Year
Harendra Singh Rawat,BCA 2nd YearHarendra Singh Rawat,BCA 2nd Year
Harendra Singh Rawat,BCA 2nd Year
 
Brijesh Peswani,BCA 2nd Year
Brijesh Peswani,BCA 2nd YearBrijesh Peswani,BCA 2nd Year
Brijesh Peswani,BCA 2nd Year
 
Gaurav Singh Chouhan, BCA 2nd Year
Gaurav Singh Chouhan, BCA 2nd YearGaurav Singh Chouhan, BCA 2nd Year
Gaurav Singh Chouhan, BCA 2nd Year
 
Mithlesh Singh Rawat, BCA 2nd Year
Mithlesh Singh Rawat, BCA 2nd Year Mithlesh Singh Rawat, BCA 2nd Year
Mithlesh Singh Rawat, BCA 2nd Year
 
Varun Kaushik, BCA 2nd Year
Varun Kaushik, BCA 2nd YearVarun Kaushik, BCA 2nd Year
Varun Kaushik, BCA 2nd Year
 

Ähnlich wie Pinkle Makhijani ,BCA 2nd Year

Presentation 4th
Presentation 4thPresentation 4th
Presentation 4th
Connex
 
22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf
PradipShinde53
 

Ähnlich wie Pinkle Makhijani ,BCA 2nd Year (10)

Sudarshan Joshi,BCA 2nd Year
Sudarshan Joshi,BCA 2nd Year Sudarshan Joshi,BCA 2nd Year
Sudarshan Joshi,BCA 2nd Year
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
BCA 2nd year Java prog. File
BCA 2nd year Java prog. FileBCA 2nd year Java prog. File
BCA 2nd year Java prog. File
 
Pooja Sharma , BCA Third Year
Pooja Sharma , BCA Third YearPooja Sharma , BCA Third Year
Pooja Sharma , BCA Third Year
 
Kirti Kumawat
Kirti KumawatKirti Kumawat
Kirti Kumawat
 
Samarth Gaur ,BCA 2nd Year
Samarth Gaur ,BCA 2nd YearSamarth Gaur ,BCA 2nd Year
Samarth Gaur ,BCA 2nd Year
 
Akshay Sharma,BCA,2nd year
Akshay Sharma,BCA,2nd yearAkshay Sharma,BCA,2nd year
Akshay Sharma,BCA,2nd year
 
Ravi Prakash,BCA,2nd Year
Ravi Prakash,BCA,2nd YearRavi Prakash,BCA,2nd Year
Ravi Prakash,BCA,2nd Year
 
Presentation 4th
Presentation 4thPresentation 4th
Presentation 4th
 
22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf
 

Mehr von dezyneecole

Mehr von dezyneecole (20)

Gracika Benjamin , Diploma Fashion Design Second Year
Gracika Benjamin , Diploma Fashion Design Second YearGracika Benjamin , Diploma Fashion Design Second Year
Gracika Benjamin , Diploma Fashion Design Second Year
 
Sheikh Anjum Firdoush , Diploma Fashion Design Second Year
Sheikh Anjum Firdoush , Diploma Fashion Design Second YearSheikh Anjum Firdoush , Diploma Fashion Design Second Year
Sheikh Anjum Firdoush , Diploma Fashion Design Second Year
 
Harsha Chhaparwal, Diploma Fashion Design Second Year
Harsha Chhaparwal, Diploma Fashion Design Second YearHarsha Chhaparwal, Diploma Fashion Design Second Year
Harsha Chhaparwal, Diploma Fashion Design Second Year
 
Harsha Chhaparwal, Diploma Fashion Design Second Year
Harsha Chhaparwal, Diploma Fashion Design Second YearHarsha Chhaparwal, Diploma Fashion Design Second Year
Harsha Chhaparwal, Diploma Fashion Design Second Year
 
Harsha Chhaparwal, Diploma Fashion Design Second Year
Harsha Chhaparwal, Diploma Fashion Design Second YearHarsha Chhaparwal, Diploma Fashion Design Second Year
Harsha Chhaparwal, Diploma Fashion Design Second Year
 
Sheikh Anjum Firdoush , Diploma Fashion Design Second Year
Sheikh Anjum Firdoush , Diploma Fashion Design Second YearSheikh Anjum Firdoush , Diploma Fashion Design Second Year
Sheikh Anjum Firdoush , Diploma Fashion Design Second Year
 
Sushmita Bhati, Diploma Fashion Design Second Year
Sushmita Bhati, Diploma Fashion Design Second YearSushmita Bhati, Diploma Fashion Design Second Year
Sushmita Bhati, Diploma Fashion Design Second Year
 
Sushmita Bhati, Diploma Fashion Design Second Year
Sushmita Bhati, Diploma Fashion Design Second YearSushmita Bhati, Diploma Fashion Design Second Year
Sushmita Bhati, Diploma Fashion Design Second Year
 
Sushmita Bhati, Diploma Fashion Design Second Year, (How to Design for Fashio...
Sushmita Bhati, Diploma Fashion Design Second Year, (How to Design for Fashio...Sushmita Bhati, Diploma Fashion Design Second Year, (How to Design for Fashio...
Sushmita Bhati, Diploma Fashion Design Second Year, (How to Design for Fashio...
 
Somya Jain, Diploma Fashion Design Second Year, (How to Design for Fashion In...
Somya Jain, Diploma Fashion Design Second Year, (How to Design for Fashion In...Somya Jain, Diploma Fashion Design Second Year, (How to Design for Fashion In...
Somya Jain, Diploma Fashion Design Second Year, (How to Design for Fashion In...
 
Gitesh Chhatwani , BCA -3 Year
Gitesh Chhatwani , BCA -3 YearGitesh Chhatwani , BCA -3 Year
Gitesh Chhatwani , BCA -3 Year
 
Anurag Yadav , B.Voc Interior Design 1st Year ( Residential Portfolio)
Anurag Yadav , B.Voc Interior Design 1st Year ( Residential Portfolio)Anurag Yadav , B.Voc Interior Design 1st Year ( Residential Portfolio)
Anurag Yadav , B.Voc Interior Design 1st Year ( Residential Portfolio)
 
Namita Bakoliya, Diploma Fashion Design First Year, (Corel Draw Project)
Namita Bakoliya, Diploma Fashion Design First Year, (Corel Draw Project)Namita Bakoliya, Diploma Fashion Design First Year, (Corel Draw Project)
Namita Bakoliya, Diploma Fashion Design First Year, (Corel Draw Project)
 
Sheikh Anjum Firdoush , Diploma Fashion Design Second Year, (Pattern Engineer...
Sheikh Anjum Firdoush , Diploma Fashion Design Second Year, (Pattern Engineer...Sheikh Anjum Firdoush , Diploma Fashion Design Second Year, (Pattern Engineer...
Sheikh Anjum Firdoush , Diploma Fashion Design Second Year, (Pattern Engineer...
 
Sheikh Anjum Firdoush , Diploma Fashion Design Second Year, (Draping Project)
Sheikh Anjum Firdoush , Diploma Fashion Design Second Year, (Draping Project)Sheikh Anjum Firdoush , Diploma Fashion Design Second Year, (Draping Project)
Sheikh Anjum Firdoush , Diploma Fashion Design Second Year, (Draping Project)
 
Gouri Ramchandani, Diploma Fashion Design First Year, (Embroidery Project)
Gouri Ramchandani, Diploma Fashion Design First Year, (Embroidery Project)Gouri Ramchandani, Diploma Fashion Design First Year, (Embroidery Project)
Gouri Ramchandani, Diploma Fashion Design First Year, (Embroidery Project)
 
Gouri Ramchandani, Diploma Fashion Design First Year, (Corel DrawProject)
Gouri Ramchandani, Diploma Fashion Design First Year, (Corel DrawProject)Gouri Ramchandani, Diploma Fashion Design First Year, (Corel DrawProject)
Gouri Ramchandani, Diploma Fashion Design First Year, (Corel DrawProject)
 
Dimple Mordani, Diploma Fashion Design First Year, (illustration for Fashion ...
Dimple Mordani, Diploma Fashion Design First Year, (illustration for Fashion ...Dimple Mordani, Diploma Fashion Design First Year, (illustration for Fashion ...
Dimple Mordani, Diploma Fashion Design First Year, (illustration for Fashion ...
 
Dimple Mordani, Diploma Fashion Design First Year, (Design Basics Project)
Dimple Mordani, Diploma Fashion Design First Year, (Design Basics Project)Dimple Mordani, Diploma Fashion Design First Year, (Design Basics Project)
Dimple Mordani, Diploma Fashion Design First Year, (Design Basics Project)
 
Dimple Mordani, Diploma Fashion Design First Year, (Corel Draw Project)
Dimple Mordani, Diploma Fashion Design First Year, (Corel Draw Project)Dimple Mordani, Diploma Fashion Design First Year, (Corel Draw Project)
Dimple Mordani, Diploma Fashion Design First Year, (Corel Draw Project)
 

KĂŒrzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

KĂŒrzlich hochgeladen (20)

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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Pinkle Makhijani ,BCA 2nd Year

  • 1. INFORMATION TECHNOLOGY PROJECT REPORT JAVA PROGRAMMING TOPIC Wrapper class and Nesting Method SUBMITTED BY PINKLE MAKHIJANI BCA – IInd Year Dezyne E’cole College www.dezyneecole.com R
  • 2. Project Report On Java Programming At Dezyne E’cole College Ajmer Submitted to Dezyne E’cole College Towards the Partial Fulfillment on Bachelors of Computer Application By Pinkle Makhijani Dezyne E’cole College 106/10,Civil Lines,Ajmer Tel:-0145-2624679 www.dezyneecole.com 2016-17 R
  • 3. Acknowledgement I Pinkle Makhijani, Student Of Dezyne E’cole College , Am Extremely Grateful To Each And Every Individual Who Has Contributed In Successful Completion Of My Project. I Express My Gratitude Towards Dezyne E’cole College For Their Guidance And Constant Supervision As Well As For Providing The Necessary Information And Support Regarding The Completion Of Project. Thank You
  • 4. Synopsis This Project Is A Minor Project Made, Based On The Theoretical Concepts Of Java. This Project Has Made Our Basic Concepts On Java Strong.
  • 5. Wrapper Classes:- As pointed out earlier,vectors cannot handel primitive datatypes like int, float, char and double.Primitive data types may be converted into object types by using the wrapper classes contained in the java.lang package.Following shows the simple data types and their correspondence Wrapper class types. Wrapper Classes For Converting Types Simple Type Wrapper Class Boolean Boolean Char Character Double Double Float Float Int Int Long Long The wrapper classeshave a member of unique methodsby handling primitive data types and objects. They are listed in the following tables. Converting Primitive Numbers to Object Numbers Using Constructor Method Constructor Calling Conversion Action Integer IntVal=new Integer(i); Primitive integer to Integer object Float FloatVal=new Float(f); Primitive float to Float object Double DoubleVal=new Double(d); Primitive double to Double object Long LongVal=new Long(l); Primitive long to Long object
  • 6. Converting Object Numbers to Primitive Numbers Using typeValue() Method Method Calling Conversion Action int i=IntVal.intValue(); Object to Primitive integer float f=FloatVal.floatValue(); Object to Primitive float long l=LongVal.longValu(); Object to Primitive long Double d=Double.val.doubleValue(); Object to Primitive double Converting Numbers to Strings Using toString() Method Method Calling Conversion Action str=Integer.toString(i); Primitive integer to string str=Float.toString(f); Primitive float to string str=Double.toString(d); Primitive double to string str=Long.toString(l); Primitive long to string Converting String Objects to Numeric Objects Using the Static Method ValueOf() Method Calling Conversion Action DoubleVal=Double.ValueOf(str); Converts string to Double Object FloatVal=Float.ValueOf(str); Converts string to Float Object IntVal=Integer.ValueOf(str); Converts string to Integer Object LongVal=Long.ValueOf(str); Converts string to Long Object Converting Numeric String to Primitive Numbers Using Parsing Methods Method Calling Conversion Action int i=Integer.parseInt(str); Converts string to primitive integer long i=Long.parseInt(str); Converts string to primitive long
  • 7. Converting Primitive Numbers to Object Numbers
  • 8. Converting Object Numbers to Primitive Numbers
  • 10. Converting String Object to Numeric Object
  • 11. Converting Numeric String to Primitive Numbers
  • 12. Autoboxing and Unboxing:- The autoboxing and unboxing feature,introduced in J2SE 5.0, facilitates the process of handling primitive data types in collections. We can use this feature to convert primitive data types to wrapper class types automatically. The compiler generates a code implicitly to convert primitive type to the corresponding wrapper class type and vice-versa. For example, consider the following statements. Double d=98.42; Double dbl=d.doubleValue(); Using the autoboxing and unboxing feature, we can rewrite the above code as: Double d=98.42; Double dbl=d; How, the Java compiler provides restrictions to perform the following conversions:  Convert from nul;l type to any primitive type.  Convert to the null type other than the identify conversion.  Convert from any class type C to any array type if C is not object.
  • 13. Vector without using Autoboxing and Unboxing
  • 14. Vector with using Autoboxing and Unboxing
  • 15. Nesting of Methods:- We discussed earlier that a method of a class can be called only by an object of that class using the dot operator. However,there is an exception to this. A method can be called by using only its name by another method of the same class. This is known as nesting of methods. Program illustrates the nesting of methods inside a class. The class Nesting defines one constructor and two methods, namely largest() and display(). The method display() calls the method largest() to determine the largest of the two numbers and then displays the result. Example of Nesting of Methods
  • 16.
  • 17. Another Example of Nesting of Methods A method can call any number of methods. It is also possible for a called method to call another method. That is, method1 may call method 2, which in turn may call method3.