Q:

What's wrong with the array I've made? 

I'm trying to run my program but it gives me this error: "Exception in thread "main" java.lang. ArrayIndexOutOfBoundsException: 0
    at Main.main(Main.java:9)"
public class Main {

    //main metode, som kører programmet. 
    public static void main(String[] args){

        //Vi deklarerer et array i en lokal variabel. 
        Person[] personer = new Person[0];
        personer[0]= new Person("Martin", 22, "Male");
        personer[1]= new Person("Mads", 25, "Male");
        personer[2]= new Person("Sofie", 20, "Female");
        personer[3]= new Person("Kasper", 26, "Male");
        personer[4]= new Person("Martin", 17, "Male");

        //Her laver vi en løkke for at udskrive alle vores objekter i vores array. 
        int i = 0; //Initialisationen. 
        while (i < 5 ) //Betingelsen. 
        {
            System.out.println("Navn: "+personer[i].getNavn()+" Alder: "+personer[i].getalder()+" Kon: "+personer[i].getkøn());
            i = i + 1;
        }
    }
}

And I've searched for the solution and the only thing I found was; What's wrong with my array? ,  which isn't the same error/problem I've. 

A:

You declared the array to have length 0:
Person[] personer = new Person[0];

And then try to put elements in it.  It looks like you want a total of 5 elements in the array, so give it length 5:
Person[] personer = new Person[5];

Think about an array like an egg carton.  There are only so many slots in the carton, which you can't change after you create the carton.  You can put an egg in a slot, or take an egg out of a slot, but you can't change the number of slots.  So once you declare an array of length 0, you can't change that length. 
If, however, you don't know the number of "slots" that your array will need - you need the size to be variable, you can use a more complex data structure called an ArrayList.  The syntax of using an ArrayList versus an Array is a bit different, but the methodology is about the same.  Here's how you could change your code to use an ArrayList, which leaves open the possibility of adding more people to the collection later. 
ArrayList<Person> personer = new ArrayList<Person>();
personer.add(new Person("Martin", 22, "Male"));
personer.add(new Person("Mads", 25, "Male"));
personer.add(new Person("Sofie", 20, "Female"));
personer.add(new Person("Kasper", 26, "Male"));
personer.add(new Person("Martin", 17, "Male"));

Then, to get an element at index i, use
personer.get(i);

