Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1.  
  2. public <T> T getRandomListEntryExcluding(List<T> list, T toExclude) {
  3. T obj;
  4. do
  5. {
  6. int random = MathUtils.randomIntInRange(0, list.size() - 1);
  7. obj = list.get(random);
  8. }
  9. while(obj.equals(toExclude));
  10.  
  11. return obj;
  12. }
  13.  
  14. calling getRandomListEntryExcluding(peacefulMobs, entityClass) where entityClass: Class<? extends EntityLiving> and peacefulMobs: List<Class<? extends EntityLiving>> fails with "Inference variable T has incompatible bounds" on java 8 and not 7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement