I have a RandomizedWrapper class. This class contains a constructor that accepts a list:
public class RandomizedWrapper{
final int upperBound = 100;
final List<RandomizerEntry<?>> randomizeList;
Map<Integer, RandomizerEntry<?>> randomizerMap;
/**
* Construct a new RandomizedWrapper instance
*
* @param randomizeList - A list containing all randomizable objects
*/
public RandomizedWrapper(final List<RandomizerEntry<?>> randomizeList) {
this.randomizeList = randomizeList;
this.randomizerMap = new HashMap<>();
}
}
I want to create a new instance of this RandomizedWrapper class. I do via the following code:
List<RandomizerEntry<ItemStack>> randomizerList = new ArrayList<>();
//stuff here
RandomizedWrapper wrapper = new RandomizedWrapper(randomizerList);//error
When I attempt to create this new object, I run into the following error:
The constructor RandomizedWrapper(List<RandomizerEntry<ItemStack>>) is undefined
This makes no sense. I very clearly have a constructor in the RandomizedWrapper class that accepts a List<RandomizerEntry<?>>
wildcards. A proposed solution by the compiler says "create a constructor that accepts this argument
". I click that, just to see what happens, and it tells me "This constructor already exists
".
Does anyone understand whats going on here? Why can't I instantiate this object?