Welcome to Westonci.ca, the Q&A platform where your questions are met with detailed answers from experienced experts. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.
Sagot :
Answer:
In Java:
import java.util.Random;
public class Main {
public static void main(String[] args) {
final int arrsize = 10;
Random rd = new Random();
int[] arr = new int[arrsize];
for (int kount = 0; kount < arrsize; kount++) {
arr[kount] = rd.nextInt(arrsize*2-1) + 1;
System.out.print(arr[kount]+" "); } }}
Explanation:
This declares the array size as a constant integer
final int arrsize = 10;
This creates a Random object
Random rd = new Random();
This declares an array of arrsize size
int[] arr = new int[arrsize];
This iterates through the array
for (int kount = 0; kount < arrsize; kount++) {
This generates the random values between 1 and arrsize * 2
arr[kount] = rd.nextInt(arrsize*2-1) + 1;
This prints the elements of the array
System.out.print(arr[kount]+" "); }
We hope this information was helpful. Feel free to return anytime for more answers to your questions and concerns. We hope this was helpful. Please come back whenever you need more information or answers to your queries. Westonci.ca is your go-to source for reliable answers. Return soon for more expert insights.