java - how to return HashSet from a method? -


i struggling how recall data stored in hashmap , hashset , method return values stored in them , size data?

public hashset <room>  getoccupiedrooms(){     return occupiedrooms.size(); } 

and not compile not sure. , wound return data stored.

cheers

you need iterate on hashset, check every room if it's occupied , add room diffferent hashset.

public hashset<room>  getoccupiedrooms(){ hashset<room> tempset = new hashset<room>(); // iterate start // if room occupied, add room tempset // iterate end // return tempset 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -