Java-Primitive Wrapper Classes

Primitive Wrapper Classes Primitive data types may be converted into object types by using the wrapper classes. These wrapper classes are available in the java.lang.package. So you can use them without an import statement. The eight wrapper classes are named in the following table. Primitive Data Type Wrapper Class boolean Boolean byte Byte char Character … Read more…

Java-Primitive Wrapper Classes to Primitive Type Using typeValue Method

Primitive Wrapper Classes to Primitive Type Using typeValue Method Method Calling Conversion Action char c = Character.charValue(); Object to primitive character int i = Integer.intValue(); Object to primitive integer float f = Float.floatValue(); Object to primitive float long l = Long.longValue(); Object to primitive long double d = Double.doubleValue(); Object to primitive double Program Program Source … Read more…

Java-Integer to Binary Octal Hexadecimal

Integer to Binary Octal Hexadecimal The toBinaryString() method produces a string containing a binary representation of the value of type int that is passed as the argument to the method. The toHexString() method produces a string containing a hexadecimal representation of the value of type int that is passed as the argument to the method. … Read more…

Java-Autoboxing and Unboxing

Autoboxing and Unboxing Autoboxing is the process by which a primitive type is automatically encapsulated(boxed) into its equivalent type wrapper whenever an object of that type is needed. There is no need to explicitly construct an object. Auto-unboxing is the process by which the value of a boxed object is automatically extracted (unboxed) from a … Read more…

Java-Autoboxing on Methods

Autoboxing on Methods In addition to the simple case of assignments, autoboxing automatically occurs whenever a primitive type must be converted into an object; auto-unboxing takes place whenever an object must be converted into a primitive type. Thus, autoboxing/unboxing might occur when an argument is passed to a method, or when a value is returned by a method. … Read more…