Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. public void skirtingiAutoriai() {
  2. Map<String, Integer> skirtingiAutoriai = new TreeMap<String, Integer>();
  3. for (Knyga w1 : knygos) {
  4. Integer sum = skirtingiAutoriai.get(w1.getAutorius());
  5. if (sum == null) {
  6. sum = 0;
  7. }
  8. sum++;
  9. skirtingiAutoriai.put(w1.getAutorius(), sum);
  10. }
  11. System.out.println("Skirtingi autoriai: " + skirtingiAutoriai.size());
  12. for (Map.Entry<String, Integer> e : skirtingiAutoriai.entrySet()) {
  13. System.out.println("Autorius: " + e.getKey() + ". Knygų skaičius: " + e.getValue());
  14. }
  15. System.out.println("---------------------------------");
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement