Arrays are objects in java, and for that we create them using new operator.
For primitive data types:
For non-primitive data types:
Once you specify the size of array, you can't change it later.
Assigning values to arrays:
For primitive data types:
For non-primitive types:
It will create objects in the heap and assign it to the the array elements.
To copy one array to another one you can use arraycopy method from System class:
It will copy values from index 1 of myStrings to copiedStrings. So copiedStrings will look like this.
For primitive data types:
For non-primitive data types:
Once you specify the size of array, you can't change it later.
Assigning values to arrays:
For primitive data types:
For non-primitive types:
It will create objects in the heap and assign it to the the array elements.
To copy one array to another one you can use arraycopy method from System class:
It will copy values from index 1 of myStrings to copiedStrings. So copiedStrings will look like this.
No comments:
Post a Comment