Java:elementAt(int) is undefined for the type
Résolu/Fermé
domxaline
Messages postés
188
Date d'inscription
lundi 16 mai 2005
Statut
Membre
Dernière intervention
7 mars 2018
-
27 juin 2012 à 17:27
domxaline - 28 juin 2012 à 11:01
domxaline - 28 juin 2012 à 11:01
A voir également:
- Method is undefined for the type java
- What is my movie français - Télécharger - Divers TV & Vidéo
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel football - Télécharger - Jeux vidéo
- Downloader for pc - Télécharger - Téléchargement & Transfert
- Java apk - Télécharger - Langages
2 réponses
domxaline
Messages postés
188
Date d'inscription
lundi 16 mai 2005
Statut
Membre
Dernière intervention
7 mars 2018
10
Modifié par domxaline le 27/06/2012 à 18:13
Modifié par domxaline le 27/06/2012 à 18:13
quand j'ecrit comme suivant:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method addElement(String) is undefined for the type String
Incompatible operand types String and int
The method addElement(String) is undefined for the type String
The method size() is undefined for the type String
The method elementAt(int) is undefined for the type String
at DupValue.main(DupValue.java:21)
la ligne 21 est
tmpVector(int).addElement(tmpValue);
aidez moi svp
for(int j=0; j<=v.size();j++) { tmpValue=(String)v.elementAt(j); if(tmpValue!=null) { if(tmpVector.isEmpty()) tmpVector.addElement(tmpValue); if (tmpVector.indexOf(tmpValue==-1)) tmpVector.addElement(tmpValue); } } for(int j=0; j<tmpVector.size(); j++) { System.out.print(tmpVector.elementAt(j)); }
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method addElement(String) is undefined for the type String
Incompatible operand types String and int
The method addElement(String) is undefined for the type String
The method size() is undefined for the type String
The method elementAt(int) is undefined for the type String
at DupValue.main(DupValue.java:21)
la ligne 21 est
tmpVector(int).addElement(tmpValue);
aidez moi svp
j'ai résolu mon problème
merci d'avance
import java.util.Vector; public class DupValue { public static void main(String[]args) { Vector v=new Vector(); v.add("Delhi"); v.add("Mumbai"); v.add("Calcutta"); v.add("Chennai"); v.add("Delhi"); Vector tmpVector=new Vector(); String tmpValue; for(int j=0; j<v.size();j++) { tmpValue=(String)v.elementAt(j); if(tmpValue!=null) { if(tmpVector.isEmpty()) { tmpVector.addElement(tmpValue); } if (tmpVector.indexOf(tmpValue)==-1) { tmpVector.addElement(tmpValue); } } } for(int j=0; j<tmpVector.size(); j++) { System.out.print(tmpVector.elementAt(j)+","); } } }
merci d'avance