In my code
for(int i=1; i<submenuCap.toString().length();i++){
String[] parts = captionRes.getString(i).split("[*]");
String part1 = parts[0];
String part2 = parts[1];
System.out.println("First parts: "+part1+" 2nd Part: "+part2);
}
Here in my submenuCap.toString.length()
is 30, and some values are like ""
, "LOTO Equipment Issue & Return Record*0"
and "Some Equipment Issue & Return Record*1"
etc..
I want to split only when data != ""
, then get last index values either 0 or 1 according to data, but here I am getting o/p
First parts: LOTO Energy Isolation Record 2nd Part: 0
First parts: LOTO Equipment Issue & Return Record 2nd Part: 0
First parts: UPS Visitor Entry Record 2nd Part: 0
First parts: Daily Technical Observation Record 2nd Part: 0
java.lang.ArrayIndexOutOfBoundsException: 1
at com.dao.DaoImpl.getMappingCategoryData(DaoImpl.java:240)
at com.services.ServiceImpl.getMappingCategoryData(ServiceImpl.java:30)
at com.controller.MasterController.getMappingCategoryData(MasterController.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)