Problem String et char

bob82fr Messages postés 38 Date d'inscription samedi 1 février 2003 Statut Membre Dernière intervention 13 janvier 2005 - 10 juin 2003 à 18:41
cs_Melchia Messages postés 1 Date d'inscription mardi 22 avril 2003 Statut Membre Dernière intervention 28 avril 2004 - 28 avril 2004 à 12:36
lut!

comment convertir un char en String, et inversement?

merici
a++

2 réponses

cs_Duss Messages postés 890 Date d'inscription lundi 8 avril 2002 Statut Membre Dernière intervention 29 juillet 2004 11
11 juin 2003 à 09:05
salut,
tu as une methode toCharArray() dans String qui te retourne un tableau de char
sinon tu peux aussi faire un String.valueOf(mavariablechar);
pour transformer un char en String
Duss
0
cs_Melchia Messages postés 1 Date d'inscription mardi 22 avril 2003 Statut Membre Dernière intervention 28 avril 2004
28 avril 2004 à 12:36
Exemple d'utilisation de ToCharArray :

class toCharArray_Example {
public static void main(String[] args) {
String strChaine = new String("Chaîne d'essai");
char[] c = strChaine.toCharArray();
for(int i = 0; i <= c.length; i++)
System.out.println(c[i]);
}
}
0
Rejoignez-nous