Scanner problem z wczytywaniem danych.

0

Witam.

Zadaniem programy jest wczytać dane studenta do tablicy niestety wyskakuje mi błąd.

Exception in thread "main" java.lang.NullPointerException
	at Main.main(Main.java:16)

Nie bardzo rozumiem o co chodzi, a tu kod programu.

import java.util.Scanner;


public class Main {

	
	public static void main(String[] args) {
		
		Scanner wczytywanieDanych = new Scanner(System.in);
		System.out.println("Podaj ilu studentów chcesz dodać");
		int i= wczytywanieDanych.nextInt();
		Student[] tablicaStudentow = new Student[i];		
		for(int p=0;p<i;p++){
			wczytywanieDanych.nextLine();
			System.out.println("Podaj nazwisko studenta");
			tablicaStudentow[p].nazwisko = wczytywanieDanych.nextLine();
			System.out.println("Podaj nazwisko imie");
			tablicaStudentow[p].imie = wczytywanieDanych.nextLine();
			System.out.println("Podaj album studenta");
			tablicaStudentow[p].album = wczytywanieDanych.nextLong();
			System.out.println("Podaj rok studenta");
			tablicaStudentow[p].rok = wczytywanieDanych.nextInt();
			System.out.println("Podaj srednia studenta");
			tablicaStudentow[p].srednia = wczytywanieDanych.nextDouble();
		}
		for(int k=0;k>tablicaStudentow.length;k++){
			System.out.println(tablicaStudentow);
		}
		
	}

}
public class Student {

	String nazwisko;
	String imie;
	long album;
	int rok;
	double srednia;
	
	public Student(){
		nazwisko = "Bartek";
		imie = "Słowik";
		album = 196865;
		rok = 1;
		srednia = 4.01;
	}
	
	public Student(String nazwisko, String imie, long album, int rok, double srednia){
		
		this.nazwisko=nazwisko;
		this.imie = imie;
		this.album = album;
		this.rok = rok;
		this.srednia = srednia;
		
		
	}
	public String toString(){
		return String.format("Nazwisko %s, Imię %s, Album %d, Rok %d, Srednia %.2f",nazwisko, imie, album, rok, srednia);
	}
	
	public void wyswietl(){
		System.out.printf("-----------------------------------------------------------------------------" +
				"\nI %-20sI %-20sI %-10sI %-5sI %-10s I" +
				"\n-----------------------------------------------------------------------------",
				"Mazwisko", "Imie", "Album", "Rok", "Średnia");
		System.out.printf("\nI %-20sI %-20sI %-10dI %-5dI %-10.1f I" +
				"\n-----------------------------------------------------------------------------",
				nazwisko, imie, album, rok, srednia);
	}

}
0
Student[] tablicaStudentow = new Student[i];
         for(int p=0;p<i;p++){ 
                tablicaStudentow[i]=new Student();
                ....

1 użytkowników online, w tym zalogowanych: 0, gości: 1