Browsed by
Tag: unboxing

Array vs Arraylist java

Array vs Arraylist java

Array vs ArrayList java: Array: 1. Size must be defined during initialization itself. 2. Size can not be resized once initialized. int[] myArraySize = new int[10]; //Possible int[] myArray = new int[];¬† // Not possible 3. Size of the array calculated using length. int[] myArr = new int[9];System.out.println("size of the array : "+myArr.length); //prints 9 4. Both objects and primitives can be stored. int[] myArr = new int[9]; //Possible (primitive data type) Integer[] myArrInteger = new Integer[10]; //Possible (wrapper class…

Read More Read More

646 total views, no views today

Autoboxing and Unboxing in java

Autoboxing and Unboxing in java

Autoboxing and Unboxing in java: Autoboxing:¬†Converting primitive data type to wrapper class objects. Eg: int to Integer, double to Double, float to Float etc.., Unboxing:¬†Converting wrapper class objects to primitive data types. Eg: Integer to int, Double to double, Float to float etc..,   Autoboxing Example program: import java.util.Vector; public class Autoboxing { public static void main(String[] args) { // Autoboxing – Primitive data type to wrapper class objects. // Eg: int to an Integer, a double to a Double,…

Read More Read More

531 total views, 1 views today