Per semplicità ti consiglio di dichiarare un metodo che restituisce una stringa letta dalla consolle, ch epuoi richiamare tutte le volte che ti serve leggere qlcosa. La tua classe diverrebbe:
Codice PHP:
import java.io.*;
class Hello {
public static void main(String args[]){
String nome;
nome = read();
System.out.println ("Ciao mondo, il mio creatore si chiama: " + nome);
}
//Questo metodo legge una stringa dalla consolle e la restituisce
private String read(){
String s = "";
try{
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
s = b.readLine();
}
catch(IOException exc){
System.out.println(E' stata lanciata una IOException: " + exc);
}
return s;
}
}