public class Mains {
public static void Main (string[] args) {
Create object, object named Hello
Mains hello = new mains ();
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 an array of 100 or less random numbers
* 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<nums.length;i++) {
Generates a random number within 100 and assigns to each member of the array
int a= (int) (Math.random () *100);
Nums[i]=a;
}
return nums; Returns the array after assignment
}
}
Defines a method with a parameter return value, implementing an array of output random numbers