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
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.
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.