View Single Post
Old 13-02-2002, 11:19   #1
Grimlock
Senior Member
 
L'Avatar di Grimlock
 
Iscritto dal: Jun 2000
Cittā: Nowhere
Messaggi: 109
Java: parseInt() non funziona

Di per se il programma e' una banalita', peccato che non funzioni

Leggo da Standard Input una stringa contenente un numero e poi lo converto in intero con parseInt... pero' il compilatore mi da un errore proprio relativo al comando in oggetto

import java.io.*;

class prova {
public static void main (String[] args) throws IOException {
InputStreamReader lettore = new InputStreamReader (System.in);
BufferedReader myInput = new BufferedReader (lettore);

String str= new String();

try { str = myInput.readLine(); }
catch (IOException e) {
System.out.println ("Si č verificato un errore: " + e);
System.exit(-1);
}
System.out.println("Hai digitato: " + str);

int num;
num=str.parseInt();

.... }

L'errore ottenuto e' il seguente:

cannot resolve symbol
symbol: method parseInt ()
location: class.java.lang.String
num=str.parseInt();
__________________
"Among the winners, there is no room for the weak."
Grimlock č offline   Rispondi citando il messaggio o parte di esso