How do you edit an array?
Code :
import java.util.Random;
public class Basic{
public static void main(String[] args) {
System.out.printf("The values in the array are:\n");
Random randomNumbers = new Random();
int[] array = new int[ 5 ];
for (int num = 0; num <array.length; num++ )
array[num] = randomNumbers.nextInt(50);
for (int value = 0; value < array.length; value++ )
System.out.printf("value[ %2d ] =%4d\n", value, array[ value ]);
}
}
My program displays 5 random numbers. I want the user to be able to pick one of those numbers and be able to change it to any number they want. I have absolutely no idea how to even begin. Any help would be appreciated, this array stuff is hard to learn for me.
Re: How do you edit an array?
You edit an array exactly how you initialize an array. array[index] = whatever.
Recommended reading: http://www.javaprogrammingforums.com...e-posting.html