String Index Out of range
emna
-
Utilisateur anonyme -
Utilisateur anonyme -
Bonjour,
Je suis en train de programmer en java et j'ai l'erreur index out of range 3 ! J'ai pas compris ou est mon erreur !! Je laisse mon bout de code! Merci d'avance
try
{
IN1=new BufferedReader(new FileReader("C:\\BF.txt"));
for(int i=0;i<Inter.size();i++){
String A=new String ();
A=Inter.get(i).getPremisse();
int trouve=0;
j=0;
System.out.println("2");
while ((ligne1=IN1.readLine())!=null)
{
System.out.println("3"+ligne1.charAt(0)+" "+A.charAt(j));
while ((j<A.length())&&(ligne1.charAt(0)!=A.charAt(j))){
j++;
System.out.println("4"+ligne1.charAt(0)+" "+A.charAt(j)+"j"+j);
System.out.println("emmchiiiiiiiiiiiiiiiii");
System.out.println("j emchi"+j);
System.out.println(ligne1.charAt(0)+" "+A.charAt(j));
if (ligne1.charAt(0)==A.charAt(j))
{System.out.println("5");
trouve++;
j++;
}
}
System.out.println ("j="+j+"longueur="+A.length());
}IN1.close();} catch (Exception e) {}
Mon fichier BF contient
B
C
H
et ma liste Inter
BDE = F
GD = A
CF = A
XA = H
XC = A
XB = D
B = X
D = E
C = D
Je suis en train de programmer en java et j'ai l'erreur index out of range 3 ! J'ai pas compris ou est mon erreur !! Je laisse mon bout de code! Merci d'avance
try
{
IN1=new BufferedReader(new FileReader("C:\\BF.txt"));
for(int i=0;i<Inter.size();i++){
String A=new String ();
A=Inter.get(i).getPremisse();
int trouve=0;
j=0;
System.out.println("2");
while ((ligne1=IN1.readLine())!=null)
{
System.out.println("3"+ligne1.charAt(0)+" "+A.charAt(j));
while ((j<A.length())&&(ligne1.charAt(0)!=A.charAt(j))){
j++;
System.out.println("4"+ligne1.charAt(0)+" "+A.charAt(j)+"j"+j);
System.out.println("emmchiiiiiiiiiiiiiiiii");
System.out.println("j emchi"+j);
System.out.println(ligne1.charAt(0)+" "+A.charAt(j));
if (ligne1.charAt(0)==A.charAt(j))
{System.out.println("5");
trouve++;
j++;
}
}
System.out.println ("j="+j+"longueur="+A.length());
}IN1.close();} catch (Exception e) {}
Mon fichier BF contient
B
C
H
et ma liste Inter
BDE = F
GD = A
CF = A
XA = H
XC = A
XB = D
B = X
D = E
C = D