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
Post a Comment