Import Java.util.Arrays;
public class HelloWorld {public static void main (string[] args) {
Create object, object named Hello
HelloWorld Hello = new HelloWorld ();
Calling a method and saving the return value in a variable
int[] Nums = Hello.getarray (8);
Converts an array to a string and outputs
System.out.println (arrays.tostring (nums)); }
/* Function: Creates an array of type int of the specified length and generates a value for each element in the array that is within 100 random number
* Defines a method with the return value of the parameter, passing in the length of the array, returning the array after the assignment */
Public int[] GetArray (int length) {
Defines an integer array of the specified length
int[] Nums = new Int[length];
Iterating through an array assignment
for (int i=0;i<length;i++) {
Generates a random number within 100 and assigns to each member of the array
nums[i]= (int) (Math.random () *100);
}
return nums;
Returns the array after assignment
}
}
2014-12-01-1717-java-randomly generates an array of 8-bit numbers (100 or less)