charAt doesnt work right now i cant find the failure

37 views Asked by At

My code doesnt work at line 64 i wanted that the compiler shows me the first index of the firstName n even of the lastName but it just says "java.lang.NullPointerException". i dont know what i ve done wrong it would be nice if someone could help me to find the failure n explain me what i ve done wrong.

thx :)

import util.IO;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.Period;
import java.time.chrono.ChronoLocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.time.temporal.ChronoUnit;
public class PersonUtils {


                public static void main(String[] args) {
                PersonUtils prg = new PersonUtils();
                prg.execute();
}




{
        final int PERS_ANZ_MAX=100;
        final int TAGE_MAX = 20;
        final String KLINIK ="Lausitzer Gesundbrunnen.\nCottbus und Senftenberg";
}



void execute()
        {
            patientenAbruf();
            dateCalc();
            getNextKey(null, null, null);
        }



    public void patientenAbruf() 
    {
    String name = IO.readString("Bitte den Nachnamen des Patienten eingeben:");
    String vorname = IO.readString("Bitte geben Sie den Vornamen des Patienten an:");
    }


    public LocalDate dateCalc()
    {

    LocalDate today = LocalDate.now();
    LocalDate termin=LocalDate.of(2020, 3, 1);
    Period zeit = today.until(termin);
    int yearsOftime= zeit.getYears();
    int monthsOfTime= zeit.getMonths();
    int daysOfTime= zeit.getDays();

        System.out.println("es verbleiben noch "+daysOfTime+ " Tage und "+monthsOfTime + " Monate sowie "+yearsOftime +" Jahre bis zum nächsten Termin.");
        return today;
      }


    public void getNextKey(String name, String vorname, LocalDate termin)
    {

        char firstName = vorname.charAt(1);
        char lastName = name.charAt(1);
        System.out.print(firstName + lastName);


    }
}>

Exception in thread "main" java.lang.NullPointerException at praktikum7.PersonUtils.getNextKey(PersonUtils.java:64) at praktikum7.PersonUtils.execute(PersonUtils.java:34) at praktikum7.PersonUtils.main(PersonUtils.java:16)>

0

There are 0 answers