Conversion de type en java
comment faire pour convertir un "string" en "int" en java
3 réponses
-
Bonsoir,
String s = "45"
int i = new Integer(s).intValue();
a+ -
Même chose avec un Integer, hein ;)
Tient, pour toutes les fonctions possibles:
http://java.sun.com/j2se/1.4.2/docs/api/index.html
Si tu as des erreurs, c'est probablement que tu mélanges la classe Integer et le type de données int. Va voir l'API, ça va te donner une bonne idée.
Caro -
String piStr = "3.14159"; Float pi = Float.valueOf(piStr);
(http://java.sun.com/docs/books/tutorial/java/data/andback.html)
Car0