-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathWrapperClass
31 lines (25 loc) · 1.02 KB
/
WrapperClass
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
Java is not 100% OOP because it can have primitive type variables like int float etc
but wrappper class gives a solution. instead of creating primitive variables. we can store our
data into wrapper classes.
for eg
Integer is a wrapper class which stores int values . But since Integer is a class not primitive variabele
hence we can say that now every things is object
*/
package wrapper.pkgclass;
public class WrapperClass {
public static void main(String[] args) {
// static function present in each wraper class
// takes input as integer and saves as integer
// return reference of Integer class
Integer in= Integer.valueOf("88");
//similary
Float f=Float.valueOf("5.55");
//static funtion to convert string to corresponding types
int i=Integer.parseInt("22");
//similarly
double d=Double.parseDouble("4.3");
//instance function that returns value stored in Integer class
int a =in.intValue();
}
}