In one of my class, I wrote these lines:
String[] score = {"2","3","4","5"};
player = new otherClass(score);
host = new otherClasee(score);
player.shuffle();
host.shuffle()
System.out.println("player is: " + Arrays.toString(player.point));
System.out.println("host is: " + Arrays.toString(host.point));
And the otherClass is:
public class otherClass {
String[] point;
public otherClass(String[] something){
point = something;
}
public void shuffle(){
int ind;
String change;
Random rand = new Random();
for (int i = point.length - 1; i > 0; i--){
ind = rand.nextInt(i+1);
if (ind != i){
change = point[i];
point[i] = point[ind];
point[ind] = swap;
}
}
The "shuffle()" is the method inside class "otherClass" to swap elements of point[]. But the result I receive is that "player" and "host" are shuffled in the exact same way. Specifically, the "player" is shuffled first, then "host" is later. I was expecting the two shuffles to be different.