Saturday, 14 September 2013

Out Of Bounds Expeption location (JAVA)

Out Of Bounds Expeption location (JAVA)

Can someone help me understand where the out of bounds exeption is
happening. The compiler said its here if(content[i] == delSub[j]) and out
of bounds by 5. is that really where its happening and if so why?
char[] content = new char []{'A','B','C','D','E','F','G'};
//SubString = BCDEF
public int deleteSubString(String delSubString)
{
int count = 0;
char[] delSub = new char[delSubString.length()];
String temp = "";
for(int i = 0; i < content.length;i++)
{
for (int j = 0; i < delSub.length;j++)
{
if(content[i] == delSub[j])
{
temp = temp + content[i];
}
}
}
return 0;
//TODO configure return statement conditions
}

No comments:

Post a Comment