在这个用于计算行列式的应用程序中,我使用了一个 java 解析器形式:http ://www.speqmath.com/tutorials/expression_parser_java/index.html以允许用户输入数学表达式。但应用程序崩溃
secondo = new Button (this);
secondo.setText("Fill the matrix and CALCULATE");
tableLayout.addView(secondo);
secondo.setOnClickListener(new OnClickListener(){
public void onClick(View arg0) {
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
expr[i][j] = valore[i][j].getText().toString();
matrix[i][j] = prs.parse(expr[i][j]);
}
}
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
int index1 = matrix[i][j].indexOf("=");
matrix1[i][j] = matrix[i][j].substring(index1+2);
}
}
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
vettore1[i][j] = Double.parseDouble(matrix1[i][j]);
}
}
Matrix A = new Matrix(vettore1);
det = A.det();
这段代码给了我这个错误:
06-07 17:59:09.138: E/AndroidRuntime(2420): FATAL EXCEPTION: main
06-07 17:59:09.138: E/AndroidRuntime(2420): java.lang.NumberFormatException:
06-07 17:59:09.138: E/AndroidRuntime(2420): at org.apache.harmony.luni.util.FloatingPointParser.parseDblImpl(Native Method)
06-07 17:59:09.138: E/AndroidRuntime(2420): at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:283)
06-07 17:59:09.138: E/AndroidRuntime(2420): at java.lang.Double.parseDouble(Double.java:287)
06-07 17:59:09.138: E/AndroidRuntime(2420): at java.lang.Double.valueOf(Double.java:326)
06-07 17:59:09.138: E/AndroidRuntime(2420): at it.bisemanuDEV.matrixDET.SecondaAttivita$1.onClick(SecondaAttivita.java:143)
06-07 17:59:09.138: E/AndroidRuntime(2420): at android.view.View.performClick(View.java:2408)
06-07 17:59:09.138: E/AndroidRuntime(2420): at android.view.View$PerformClick.run(View.java:8819)
06-07 17:59:09.138: E/AndroidRuntime(2420): at android.os.Handler.handleCallback(Handler.java:603)
06-07 17:59:09.138: E/AndroidRuntime(2420): at android.os.Handler.dispatchMessage(Handler.java:92)
06-07 17:59:09.138: E/AndroidRuntime(2420): at android.os.Looper.loop(Looper.java:123)
06-07 17:59:09.138: E/AndroidRuntime(2420): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-07 17:59:09.138: E/AndroidRuntime(2420): at java.lang.reflect.Method.invokeNative(Native Method)
06-07 17:59:09.138: E/AndroidRuntime(2420): at java.lang.reflect.Method.invoke(Method.java:521)
06-07 17:59:09.138: E/AndroidRuntime(2420): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-07 17:59:09.138: E/AndroidRuntime(2420): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-07 17:59:09.138: E/AndroidRuntime(2420): at dalvik.system.NativeStart.main(Native Method)