-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaWrapperClass.java
More file actions
38 lines (34 loc) · 1.19 KB
/
JavaWrapperClass.java
File metadata and controls
38 lines (34 loc) · 1.19 KB
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
32
33
34
35
36
37
38
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package oops2;
/**
*
* @author Sunil Shetty
*/
//wrapper class provide a way to use primitive data types as objects
import java.util.*;
public class JavaWrapperClass {
public static void main(String[]args){
//creating wrapper objects
Integer myInt=5;
Double myDouble=5.99;
Character myChar = 'a';
System.out.println(myInt);
System.out.println(myDouble);
System.out.println(myChar);
/*here we are using wrapper object so we have different methods
to get the value associated with the corresponding wrapper object
*/
System.out.println(myInt.intValue());
System.out.println(myDouble.doubleValue());
System.out.println(myChar.charValue());
//toString() used to convert wrapper object to string
Integer myint=150;
String mystring = myint.toString();
System.out.println(mystring.length());
System.out.println(mystring);
}
}