jeudi 20 juin 2019

Is there a way to create an array in java with some initialized numbers and then add random numbers to it

I am trying to create an array with 7 numbers that are manually inputted and 43 that random.

I am able to do it in C but I am facing a challenge in java the 7 numbers that are manually inputted keep coming out as zeros when the array is printed

int arr3[]= {1,2,3,4,5,6,7}; // this is where I created the array 
arr3=new int[50];

// this is where I tried to populate it

for (int i = 7; i < arr5.length; i++) 
{
arr3[i] = (int) (Math.random() * 1500);
} 

I would like the first few numbers to be manually inputted and the rest to be randomly created




Aucun commentaire:

Enregistrer un commentaire