为什么我在这两行继续得到java.lang.NullPointerException?

时间:2013-09-19 23:01:39

标签: arrays memory-management methods thread-synchronization

double [] readCoeffs(){//读取系数方法从这里开始

double[]coeffsArray1 = new double[3];


    try                    {    

            System.out.print("Please enter a real number for the A coefficent of your quadratic equation: ");

            coeffsArray1[0] = in.nextDouble();
            System.out.print("Please enter a real number for the B coefficent of your quadratic equation: ");
            coeffsArray1[1] = in.nextDouble();
            System.out.print("Please enter a real number for the C coefficent of your quadratic equation: ");
            coeffsArray1[2] = in.nextDouble();
                            }
        catch(NumberFormatException e){
            System.out.println("Please enter real numbers for all of your coefficients.");
                                      }
        return coeffsArray1;
                    }

public void run(){ 而(真){

尝试{     // double [] coeffsArray = new double [3]; //实例化一个双数组来存储传入的系数

for (int i =0; i<2; i++){  //outer loop runs as many times as the number of equations you want to solve
    coeffsArray = readCoeffs();  //run read coefficient method each time you want coefficients for each equation. Reuse the same area for storing and sengind coeeficients through the pipes

        for(int k=0; k<3; k++){     //inner loop 
            outfirst.writeDouble(coeffsArray[k]);  // Pipe's end object is written into with double coefficients individually from the equations array through a data stream 
                              }
                                }  //closes  for loop   

睡眠(1500); //睡眠500毫秒 outfirst.flush(); //刷新管道让下一个线程不能继续    } //结束尝试

0 个答案:

没有答案