Tuesday, 15 July 2014

java - Adding Random numbers into a heap -


According to Eclipse, I do not have permission to add a random number array list directly to my "Comparable" parameter I have no clue how to add them.

  Random Generator = New Random (777); Minhap MH = New Minhap (); For (int i = 0; i  

This is my method to add (in another category)

  add public zeroes (comparative new elements) {// A new address element Add. Add (zero); Int Index = Elements () - 1; // Demonstrate older parents than the new element / this last "comparator" & lt; Maximum Hap and & gt; While for Minhap (index> 1 & amp; amp; and; mount paper (index) .comparareto (newElement) <0) {elements.set (index, getParent (index)); Index = found pattern index (index); } // Set the new element in empty slot elements .set (index, new element);  

} I get this error: java.util.Random can not be entered in java.lang.

Why ??

generator , which is an object instead of random

random value you can use the generator

you The value of the integer can be automatically boxed which try comparative

:

  integer rand = generator. NiextInt (100); Println (rand); Mh.add (rand);  

No comments:

Post a Comment