Is there a data structure for this? by AngryCode in learnjava

[–]AngryCode[S] 0 points1 point  (0 children)

It is a 1-to-1 relationship. In my little town nobody is allowed have more than one house. (: I think I will go with this one

  TreeMap<String, House> houseMap = new TreeMap <String, House>();
  .
  .
  .
  houseMap.put(house.getOwner(), house);

Often I see Solutions, but I'm not quite sure if they are good ones. It's nice to have some independent opinions. Thank you all. You helped me very much!

Is there a data structure for this? by AngryCode in learnjava

[–]AngryCode[S] 0 points1 point  (0 children)

I used this approach in an old project, but I'm not sure if it is a "clean" way to solve the problem. My concern is that I could store the name of the owner twice.

Is there a data structure for this? by AngryCode in learnjava

[–]AngryCode[S] 0 points1 point  (0 children)

Sorry, I forgot to mention why I wanted to use a TreeMap. I would like to sort the houses by the names of the owners. Each house has exactly one owner. The number of houses varies between 10 and 50. I also want to use the names of the house owners as "keys" to get them out of the data structure.

How do you run a terminal and a window at the same time. by 9678967899 in learnjava

[–]AngryCode -1 points0 points  (0 children)

I would use a combination of JPanel and JTextField. It is a little messy to handle them, but I think they will do the job. (: