Grimlock
13-02-2002, 11:19
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 :mad:
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();
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 :mad:
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();