The problem I'm having is that I have a min heap class that is created with java generics. In the class where I use the min heap class(call it sorter) I have a float array, which is full of primitive float values.

The constructor for the min-heap class takes a AnyType as a parameter. Now, creating a minHeap object(in the Sorter class) and trying to pass it a float array does not make java happy.

I'm trying to figure out how I can get my float values into the min-heap while still keeping java generics in the min-heap class.

The constructor for Min-Heap looks like this:

public Heap(AnyType [] f){

I have been calling the mean heap class in Sorter like this:

heap = new Heap(f); //f is a float[] f;

Any help would be appreciated. Looking around I've been seeing stuff about wrapping it in a Float object but don't know how to wrap the array.

You can 'wrap' the array by creating a new Float[] array and then in a for loop, add each float primitive type to the Float array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.