How to Use Wrapper Methods in Java


In this example we will show you how to use wrapper methods in Java.

Source Code

package com.beginner.examples;

public class WrapperMethod { 
  public static void main(String[] args) { 
    Integer i = 1; 
    Double d = 3.14; 
    Character c = 'a';
    // use wrapper methods
    System.out.println(i.intValue());
    System.out.println(d.doubleValue());
    System.out.println(c.charValue());
  }
}

Output:

1
3.14
a
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments