Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

java.lang.StringIndexOutOfBoundsException

843810Apr 28 2010 — edited May 20 2010
Hello Everyone,

I am getting same error as

java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:558)

Here is the code:

String resourceNo[] = p_request.getStringValues(RESOURCENO);
int resLength = resourceNo.length ;
String unitSerial[] = getReqStringValues(p_request,UNITSERIAL,resLength) ;
String numOfUnit[] = getReqStringValues(p_request,UNITNO,resLength) ;
String unitType[] = getReqStringValues(p_request,UNITTYPE,resLength) ;
String allowsplit[] = getReqStringValues(p_request,ALLOWSPLIT,resLength) ;
String moveunit[] = getReqStringValues(p_request,MOVEUNIT,resLength) ;
String processallocation[] = getReqStringValues(p_request,PROCESSALLOCATION,resLength) ;
String confirmallocation[] = getReqStringValues(p_request,CONFIRMALLOCATION,resLength);

char uType ='E';
double NoOfUnits = 0;
double SConversion = 0;
double LConversion = 0;
double PConversion = 0;
double DConversion = 0;
AllocateProductStat allocPrd = null;
for (int i = 0; i < resourceNo.length; i++) {
if((resourceNo.trim()!= null) && !(resourceNo[i].equals(" "))&& (resourceNo[i].trim().length()>1)){
allocPrd = new AllocateProductStat();
allocPrd.setResourceNbr(Product.getProductCode(resourceNo[i]).trim());
allocPrd.setAgainstInv(YES) ;
uType = unitType[i].charAt(0); // this is the line where i am getting error
ProductSingleton productRetriever = ProductSingleton.getInstance() ;
Product prod = productRetriever.getProduct(resourceNo[i].trim());
ProductPackage productPkg = null;
try {
productPkg = prod.getPackaging() ;
SConversion = productPkg.getLamps(ProductUnit.CARTON,1) ;
LConversion = productPkg.getLamps(ProductUnit.LAYER,1) ;
PConversion = productPkg.getLamps(ProductUnit.PALLET,1) ;
DConversion = productPkg.getLamps(ProductUnit.DOUBLE,1) ;
} catch (LazyUpdateIncompleteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


I am not sure why it is coming there need help ASAP
Thanks for all your effort

Edited by: Oak99 on Apr 28, 2010 6:02 AM

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 17 2010
Added on Apr 28 2010
3 comments
225 views