这个问题在这里已有答案:
protected String doInBackground(String... strings) {
hashMap=new HashMap<String, String>();
hashMap.put("firstname",strings[0]);
hashMap.put("lastname",strings[1]);
hashMap.put("email",strings[2]);
hashMap.put("password",strings[3]);
finalResult=httpParse.postRequest(hashMap,httpUrl);
return finalResult;
}
这是android studio调用Index out of bound错误的代码 .
引起:java.lang.ArrayIndexOutOfBoundsException:length = 0;在com.example.fayaz.registration.MainActivity $ 1UserRegisterClass.doInBackground(MainActivity.java:98)的index = 0,位于android.os的com.example.fayaz.registration.MainActivity $ 1UserRegisterClass.doInBackground(MainActivity.java:76) . 位于java.util的java.util.concurrent.FutureTask.run(FutureTask.java:237)中的AsyncTask $ 2.call(AsyncTask.java:295)位于java.util的android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:234) .concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:588)at java.lang.Thread.run(Thread.java:818)
1 回答
您正在使用varargs
doInBackground(String... strings)
strings数组的长度为0,因此ArrayIndexOutOfBoundsException .