python空指针异常_java错误消息空指针异常

这是我在下面运行我的代码时收到的错误。我的老师说我们可以在任何地方寻求帮助。如果有人能帮助我解决这个错误,我将非常感激

java.lang.NullPointerException

at Practise_Assessment.main(Practise_Assessment.java:35)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:272)这是我的代码,如果需要的话

import java.text.NumberFormat;

import java.util.Arrays;

public class Practise_Assessment {

public static String absences(String prompt) {// user input for name and

// days absent

System.out.println(prompt);

java.util.Scanner keyboard = new java.util.Scanner(System.in);

return keyboard.nextLine();

}

public static void main(String[] args) throws Exception {

int numDayEntries ;

int numNameEntries;

int[] daysArray = null ;

String[] nameArray = null ;

boolean done = false;

while (!done) {

System.out.println("enter # to stop");

String absences = absences("enter name of person absent then the amount of days they were absent");// the value of the users input

for(numDayEntries =0; numDayEntries < daysArray.length;numDayEntries++ ){

daysArray = new int[numDayEntries];

}

for(numNameEntries = 0; numNameEntries < nameArray.length;numNameEntries++ ){

nameArray = new String[numNameEntries];

}

if (absences.equalsIgnoreCase("#")) {

done = true;

} else {

String DaysAbsent =absences.replaceAll("[^0-9]", "") ;

int daysAbsent = ((Number) NumberFormat.getInstance().parse(DaysAbsent)).intValue();// converts a string to an int

String absentee = absences.replaceAll("\\d", "");// replace all digits in the user input to nothing leaving just the name

daysArray[numDayEntries] = daysAbsent;

nameArray[numNameEntries] = absentee;

}

}

System.out.println(Arrays.toString(daysArray));

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值