I know this question sounds stupid for several members here, but i have no idea anymore.
I faced a strange problem with array. I try to get the index 1
on ArrayList
but it always throws java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
.
I have debug by the following code :
for (int o=0; o<vcard.size(); o++){
if(vcard.get(o).contains(":")){
System.out.println("Contains");
String[] splitByTitikDuaVCard = vcard.get(o).split(Pattern.quote(":"));
//this line show the length is 2
System.out.println("RESULT LENGTH : " + splitByTitikDuaVCard.length );
for (int y=0; y<splitByTitikDuaVCard.length; y++){
System.out.println("RESULT Y : " + splitByTitikDuaVCard[y] + ", INDEX : " + y);
mapContentTerbaruVCard.put(splitByTitikDuaVCard[0], splitByTitikDuaVCard[1]);
}
}else{
System.out.println("Not Contains");
}
}
The result of the log
:
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT LENGTH : 2
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : BEGIN, INDEX : 0
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : VCARD, INDEX : 1
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT LENGTH : 2
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : VERSION, INDEX : 0
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : 3.0, INDEX : 1
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT LENGTH : 2
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : N, INDEX : 0
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : Doe;John, INDEX : 1
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT LENGTH : 2
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : FN, INDEX : 0
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : John Doe, INDEX : 1
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT LENGTH : 2
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : ORG, INDEX : 0
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : PT. Pertamina, INDEX : 1
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT LENGTH : 2
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : TITLE, INDEX : 0
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : Bussiness Manager, INDEX : 1
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT LENGTH : 2
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : ADR, INDEX : 0
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : ;;Soekarno Hatta;Bandung;;46153;West Jave, INDEX : 1
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT LENGTH : 2
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : TEL;WORK;VOICE, INDEX : 0
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : 021 203312, INDEX : 1
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT LENGTH : 2
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : TEL;CELL, INDEX : 0
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : +62818456463111, INDEX : 1
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT LENGTH : 1
03-08 23:00:18.594 8350-8350/? I/System.out: RESULT Y : TEL;FAX, INDEX : 0
The log
show that the index 1
is exist, but when i try to put the index 1
into HashMap
, the error java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
is appears
My Question is : How to find the index 1
so i can save it into hashmap
Note : i have try this (Java ArrayList IndexOutOfBoundsException Index: 1, Size: 1) solution but not working on my case.