Ok, so to add an element to the end of an array, you have to create a larger array and do some copying, so something like this:
public static int[] addToArray(int[] arr, int ele, int...
Type: Posts; User: aesguitar
Ok, so to add an element to the end of an array, you have to create a larger array and do some copying, so something like this:
public static int[] addToArray(int[] arr, int ele, int...
public static int[] addArray(int[] arr1, int[] arr2) //1.
{
int[] arrFin = new int[arr1.length+arr2.length]; //2.
System.arraycopy(arr1, 0,...
It would be the copy array method. It can easily be used to add elements to an array, or at least two arrays. Observe...
public static int[] addArray(int[] arr1, int[] arr2)
{
int[]...
Well, by add, I took it as you have array arr1[] with size 5 and you want to add a sixth element. If that's the case, then there's a method in System to do it for you.
System (Java 2 Platform SE...
Wouldn't that method set the object at that index to "anObject", that wouldn't add an element, only change it, right?