java.lang.NullPointerException错误

java.lang.NullPointerException错误,java,Java,这是显示错误的程序示例运行的一部分 Please enter your the number of your selection : 5 Enter the blood Type : b Exception in thread "main" java.lang.NullPointerException at Hospital.getNumberOfPatientsBlood(Hospital.java:136) at Hospital.main(Hospital.java:71) 我有这个错误

这是显示错误的程序示例运行的一部分

Please enter your the number of your selection : 5
Enter the blood Type : b
Exception in thread "main" java.lang.NullPointerException
at Hospital.getNumberOfPatientsBlood(Hospital.java:136)
at Hospital.main(Hospital.java:71)
我有这个错误,我不知道怎么了。它应该给我一个信息,说有一个零病人的血型是B

这是显示错误的部分:

方法:

   public static int getNumberOfPatientsBlood( String bloodT ){

  int bloodTypeCount=0;
  for (int j =0; j<hospitalPatient.length;j++){

     if (hospitalPatient[j].equals(bloodT))
        bloodTypeCount++;

     else

        continue; 

  }
  return -1 ;

   }

我猜hospitalPatient为空,请先初始化它。

如何填充
hospitalPatient
数组?是否初始化了hospitalPatient数据结构?
        case 5:
           input.nextLine();              
           System.out.print("Enter the blood Type : ");
           String searchBloodType = input.nextLine();

           if (getNumberOfPatientsBlood(searchBloodType)!=-1)
              System.out.println("the total number of patients having the same Blood Type: "+getNumberOfPatientsBlood(searchBloodType));

           break;