Erro de compilação bufferedreader

4 respostas
Z
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
/**
 *
 * @author zafar
 */
public class GetInputFromKeyboard {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        BufferedReader dataIn = new BufferedReader(new inputStreamReader(System.in));
        String name = "";
        System.out.println("Please enter your Name:");
        try {
            name = dataIn.readLine();
        } catch (IOException e) {
            System.out.println("Error!");
        }
        System.out.println("Hello " + name + "!");
    }

    private static class inputStreamReader {

        public inputStreamReader(InputStream in) {
        }
    }

}

Tentei compilar o código acima no netbeans mas ocorreu o erro abaixo. Não sei o que é.

cannot find symbol
symbol  : constructor BufferedReader(GetInputFromKeyboard.inputStreamReader)
location: class java.io.BufferedReader
        BufferedReader dataIn = new BufferedReader(new inputStreamReader(System.in));

4 Respostas

Mephy

a sua linha 19 apresenta parâmetro incorreto .-.
ela pede um objeto de uma classe que não é a sua pra rodar o construtor

ViniGodoy

Depois do new a palavra InputStreamReader deve ser escrita com letras maiúsculas.
BufferedReader dataIn = new BufferedReader(new [color=red]I[/color]nputStreamReader(System.in));

Z

ViniGodoy:
Depois do new a palavra InputStreamReader deve ser escrita com letras maiúsculas.
BufferedReader dataIn = new BufferedReader(new [color=red]I[/color]nputStreamReader(System.in));

funcionou.

ViniGodoy

Procure usar uma IDE para evitar esse tipo de erro.
Ler as mensagens e usar o depurador também ajuda muito.

É mais rápido do que recorrer ao GUJ.

Criado 10 de abril de 2011
Ultima resposta 11 de abr. de 2011
Respostas 4
Participantes 3