banniwe
Messages postés13Date d'inscriptionvendredi 31 octobre 2008StatutMembreDernière intervention22 mai 2009
-
18 mars 2009 à 17:43
banniwe
Messages postés13Date d'inscriptionvendredi 31 octobre 2008StatutMembreDernière intervention22 mai 2009
-
19 mars 2009 à 01:44
banniwe
Messages postés13Date d'inscriptionvendredi 31 octobre 2008StatutMembreDernière intervention22 mai 20092 18 mars 2009 à 18:11
bonjour,
désolé le premier message n'est pas passé.
Jai une phrase en entrée et je dois creer un index des mots indiquant leurs position dans la phrase . Pour cela je creer un ArrayList principal contenant des Arraylist secondaire. Chaque ArrayListe secondaire contient un mot et ses position dans la phrase.
voici le constructeur de la ArryList principal :
ArrayList myArr = new ArrayList();
est -il correct , si oui quelqu'un pourait il m'expliquer la signification de ""?
Avec eclipse , le programme se lance mais fait une bloucle infini affichant "abs". Quand je le compile avec la console le programme s"execute normalement .
Jai juste 5 warning.
voici mon code:
import java.io.*;
import java.util.*;
public class Test
{
public static void main(String[] args)
{
try
{
ArrayList myArr = new ArrayList();
myArr.add(new ArrayList());
ArrayList tmp = myArr.get(myArr.size() - 1);
tmp.add("mot");
tmp.add("1");
int taille =myArr.size();
for (int i = 0; i <taille ; i++)
{
ArrayList tmp3 = myArr.get(i);
if (tmp3.contains("mot2"))
{
System.out.println("present");
tmp3.add("2");
} //if
else
{
System.out.println("abs");
myArr.add(new ArrayList());
ArrayList tmp4 = myArr.get(myArr.size()-1);
tmp4.add("mot2");
tmp4.add("2");
}//else
}//for
System.out.println(myArr);
} //try
catch (OutOfMemoryError parException)
{
System.out.println("Impossible d'allouer plus de memoire");
System.exit(1);
}//catch
}//main
}//class
voici les warning:
Test.java:15: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
tmp.add("mot");
^
Test.java:16: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
tmp.add("1");
^
Test.java:26: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
tmp3.add("2");
^
Test.java:34: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
tmp4.add("mot2");
^
Test.java:35: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
tmp4.add("2");
^
5 warnings