import java.util.Scanner; import java.io.File; import java.io.FileNotFoundException; class MainHund1{ public static void main(String[] args){ Scanner filScanner = null; try{ File fil = new File("hunder.txt"); filScanner = new Scanner(fil); } catch (FileNotFoundException exception){ System.out.println("Kan ikke finne filen hunder.txt!"); System.exit(1); } Hund[] alleHunder = new Hund[filScanner.nextInt()]; int nesteLedig = 0; filScanner.nextLine(); filScanner.nextLine(); while(filScanner.hasNextLine()){ String[] nesteLinjeArray = filScanner.nextLine().split(" "); String navn = nesteLinjeArray[0]; System.out.println(nesteLinjeArray[1]); int alder = Integer.parseInt(nesteLinjeArray[1]); String favorittgodis = nesteLinjeArray[2]; Hund hund = new Hund(navn, alder); hund.settFavorittGodis(favorittgodis); alleHunder[nesteLedig++] = hund; } for (Hund hund : alleHunder){ if (hund != null){ hund.skrivUt(); } } } }