Concatenate Two Arrays

 Concatenate Two Arrays using arraycopy Output In the above program, we’ve two integer arrays array1 and array2. In order to combine (concatenate) two arrays, we find its length stored in aLen and bLen respectively. Then, we create a new integer array result with length aLen + bLen. Now, in order to combine both, we copy each element in both arrays to result by… Continue reading Concatenate Two Arrays

Published
Categorized as 3. Arrays

Largest Element of an Array

Find the largest element in an array Output In the above program, we store the first element of the array in the variable largest. Then, largest is used to compare other elements in the array. If any number is greater than largest, largest is assigned the number. In this way, the largest number is stored in largest when it is printed.

Published
Categorized as 3. Arrays

Calculate Average Using Arrays

Output In the above program, the numArray stores the floating-point values whose average is to be found. Then, to calculate the average, we need to first calculate the sum of all elements in the array. This is done using a for-each loop in Java. Finally, we calculate the average by the formula: In this case, the total count is given… Continue reading Calculate Average Using Arrays

Published
Categorized as 3. Arrays

Calculate Standard Deviation

This program calculates the standard deviation of a individual series using arrays. To calculate the standard deviation, calculateSD() function is created. The array containing 10 elements is passed to the function and this function calculates the standard deviation and returns it to the main() function. Example: Program to Calculate Standard Deviation Output In the above program, we’ve used the… Continue reading Calculate Standard Deviation

Published
Categorized as 3. Arrays