Explore BrainMass

Require in giving criticism-remarks on the enclosed java code

The enclosed Java code was suppose to address the following problem, where I require in giving comments/criticism/remarks if possible with respect to the Java coding standards.
Problem Details: Write a Java program which defines two unconstrained arrays of user defined length n, that contain n Random numbers each and which outputs the addition of pairs of elements. For example, given {1, 2, 3} and {4, 5, 6} the output would be {5, 7, 9}.


Solution Preview

The attached code files attempts to solve the problem of creating two unconstrained arrays where the length of the arrays is given by the user at runtime.

In general it is a good software programming practice to follow variable naming conventions. For example, include abbreviated form of variable type as prefix. intArray gives a lot
more information than Array. It is also a good documenting habit to include input(s), output(s) and brief remark about the function of the method.

My comments on the following classes:

Instead of using a static array to create the array of user defined length arrayLength, it is possible to first define the arrays as members of RandomArray class and then allocate memory to them dynamically from within buildRandomArray method.
Good technique shown to create promptForInteger() and use of array references for display.
import java.util.Random;


* RandomArray - Class implementing static methods to create an array of specified size filled with random
* integers and to sum two arrays.
* @author fbergeon
* @see University of Liverpool Java Development module MSCSHR-JV-070308-01 (Sem 6 DQ1)
public class ...