for loop - java.lang.ArrayIndexOutOfBoundsException looping? -
this loop inside other loops, s[]
char array. moving char step step.what should correcting it
for(k=j; s[k]!='\0' ;k++) { s[k]=s[k+1]; }
you should realize arrays in java have length, null terminated check wrong. since access k+1
'th element inside loop, k
must not go beyond s.length - 2
.
for(k=j; k < s.length - 1 ;k++) { s[k]=s[k+1]; }
Comments
Post a Comment