P2 advance

Home > Preview

The flashcards below were created by user wolf on FreezingBlue Flashcards.


  1. Množica kreiranje
    Set<String> besede = new TreeSet();

    • besede.add("Ela");
    • besede.add("miha");

    • for(String s: besede){
    • System.out.println(s);
    • }
  2. Uporaba iteratorja
    Set<String> besede = new TreeSet();

    • besede.add("Ela");
    • besede.add("miha");

    Iterator<String> it = besede.iterator();

    • while(it.hasNext()){
    • System.out.println(it.next());
    • }
  3. Grem skozi ključe v slovarju
    HashMap<String, Integer> slovar = new HashMap();

    • slovar.put("Matej", 21);
    • slovar.put("Miha", 40);

    • for(String s: slovar.keySet()){
    • System.out.println(s);
    • }
  4. Pisanje izjem
    • public class Vaja {
    • public static void main(String[] args){
    • try{
    • stevilo(1);
    • }
    • catch(SteviloEna e){
    • System.out.println(e.getMessage());
    • }
    • catch(SteviloDva e){
    • System.out.println(e.getMessage());
    • }
    • catch(SteviloTri e){
    • System.out.println(e.GetMessage());
    • }

    }

    • public static void stevilo(int a) throws SteviloEna, SteviloDva, SteviloTri{
    • if(a == 1) throw new SteviloEna();
    • if(a == 2) throw new SteviloDva();
    • if(a == 3) throw new SteviloTri();
    • }
    • }


    class SteviloEna extends Exception{

    • public String getMessage(){
    • return "Stevilo je 1";
    • }
    • }

    • class SteviloDva extends Exception{
    • public String getMessage(){
    • return "Stevilo je 2";
    • }
    • }

    • class SteviloTri extends Exception {
    • public String GetMessage(){
    • return "Stevilo je 3";
    • }
    • }

Card Set Information

Author:
wolf
ID:
333883
Filename:
P2 advance
Updated:
2017-09-04 16:14:24
Tags:
ss
Folders:

Description:
ww
Show Answers:

Home > Flashcards > Print Preview