Click here to Skip to main content
15,884,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have problem with ArrayIndexOutOfBoundsException and I don't know how to solve it!!!
C#
converted[0][0]=converted[0][0]+dfa[0][0];
for(int i=0;i<100 && i<converted[i].length ;i++){
LandaTrance();
for(int r=0;r<27 && Alpha[r]!=null && converted[i][0]!=null && r<Alpha.length;r++){
temp=search(converted[i][0],Alpha[r]);
if(temp.compareTo(not)!=0){
    converted[i][1].concat(converted[i][1]+Alpha[r]);
    converted[i][2].concat(converted[i][2]+","+temp);


java.util.NoSuchElementException: No line foundread exception
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at nfa2dfa.NfaToDfa.converter(NfaToDfa.java:122)

[edit]Tags only - OriginalGriff[/edit]
Posted
Updated 29-Jan-12 4:46am
v3

1 solution

In the outer loop you used converted[i] but, you didn't check that
i < converted.Length
 
Share this answer
 
Comments
[no name] 29-Jan-12 10:43am    
It's a two dimensional array!how can I do that?
Shmuel Zang 29-Jan-12 10:55am    
Just write converted.length instead of converted[i].length. You can see an example for the length property with 2 dimensional arrays, at this link: http://www.leepoint.net/notes-java/data/arrays/arrays-2D.html
[no name] 29-Jan-12 10:58am    
I did what you said but still has the same error message...:(
Shmuel Zang 29-Jan-12 11:04am    
Try to change the order of the conditions in the inner loop. Put the Alpha[r]!=null condition, after the r<Alpha.length condition.
[no name] 29-Jan-12 11:34am    
thanks a lot for your help ! finally it worked :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900