Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. package hashmapa;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Iterator;
  5. import java.util.TreeMap;
  6. import java.util.Set;
  7.  
  8. public class Main {
  9. HashMap<String,Integer> oceny= new HashMap<String,Integer>();
  10. TreeMap<String,Integer> oceny2= new TreeMap<String,Integer>();
  11.  
  12. public Main(){
  13.  
  14. }
  15.  
  16. void wypelnij(){
  17. oceny.put("matematyka", 5);
  18. oceny.put("polski", 3);
  19. oceny.put("papiez", 2137);
  20.  
  21. oceny2.put("matematyka", 5);
  22. oceny2.put("polski", 3);
  23. oceny2.put("papiez", 2137);
  24.  
  25. }
  26. void usun(String przedmiot){
  27. Set set= oceny.keySet();
  28. Iterator it=set.iterator();
  29. while(it.hasNext()){
  30. if(przedmiot==it.next()){
  31. set.remove(przedmiot);
  32. }
  33. }
  34. }
  35.  
  36. void wyswietloceny(){
  37. for(String ocena: oceny.keySet()){
  38. System.out.println(ocena + " " + oceny.get(ocena));
  39. }
  40. System.out.println();
  41. for(String ocena2: oceny2.keySet()){
  42. System.out.println(ocena2 + " " +oceny.get(ocena2));
  43. }
  44.  
  45. }
  46.  
  47. public static void main(String[] args) {
  48. Main x= new Main();
  49. x.wypelnij();
  50. x.wyswietloceny();
  51.  
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement