Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hashmapa;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.TreeMap;
- import java.util.Set;
- public class Main {
- HashMap<String,Integer> oceny= new HashMap<String,Integer>();
- TreeMap<String,Integer> oceny2= new TreeMap<String,Integer>();
- public Main(){
- }
- void wypelnij(){
- oceny.put("matematyka", 5);
- oceny.put("polski", 3);
- oceny.put("papiez", 2137);
- oceny2.put("matematyka", 5);
- oceny2.put("polski", 3);
- oceny2.put("papiez", 2137);
- }
- void usun(String przedmiot){
- Set set= oceny.keySet();
- Iterator it=set.iterator();
- while(it.hasNext()){
- if(przedmiot==it.next()){
- set.remove(przedmiot);
- }
- }
- }
- void wyswietloceny(){
- for(String ocena: oceny.keySet()){
- System.out.println(ocena + " " + oceny.get(ocena));
- }
- System.out.println();
- for(String ocena2: oceny2.keySet()){
- System.out.println(ocena2 + " " +oceny.get(ocena2));
- }
- }
- public static void main(String[] args) {
- Main x= new Main();
- x.wypelnij();
- x.wyswietloceny();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement