(java beginner here) I am following this Random shuffling of an array but what i want to do is instead of randomly changing elements in an array then using it in my method. I want to make sure the order of the changing list is going from [1]..[2]..[3]..... (basically increasing) My ultimate goal is to have a table of numbers
int[] a = {1,2,3,4,5,6} then it in my method
static void shuffleArray(double[] solutionArray)
{
Random rnd = new Random();
for (int i = solutionArray.length - 1; i > 0; i++)
{
int index = rnd.nextInt(i + 1);
int value = 0;
// int charValue = value.digit(0);
String next = String.valueOf( (double) (value + 1));
System.out.println(next);
// Simple swap
double a = solutionArray[index];
solutionArray[index] = solutionArray[i];
solutionArray[i] = a;
}
}
public static void main(String[] args)
{
double[] solutionArray = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7};
double[] solution = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7};
shuffleArray(solutionArray);
shuffleArray(solution);
for (int i = 0; i < 7; i++)
{
position.setspeed(solutionArray[0]);
}
}
but when i set it or use it in a method i want it to go from 1 to 6 instead of randomly choosing an element or from the link shuffling the element.