Java Basic Problems

Wrapper class: Convert integer variable to object type in java.

In my last post I have shared about How to share and call a class from another class.Today I will share with you about type conversion process in java. For example: int to object conversion, float to object conversion etc.

By using the wrapper class primitive data types for example: int, float,long, char can be converted into object types.

 Here is the example

Integer AgeVal= new Integer(i);

Float  FltVal= new Float(f);

Double DblVal= new Double(d);

Long LngVal= new Long(l);

Here i,f,d,l  are primitive data types indicating integer, float, double and long data types.

1 thought on “Wrapper class: Convert integer variable to object type in java.”

  1. Wrapper Classes are Classes that have written to make objects from the primitive types in Java. They are used to wrap the primitive values in an object.Many thanks for sharing this.

    Like

Leave a comment