Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Code should Use a BufferedReader to read characters from the console.

package io;
import java.io.*; 
class Reader { 
  public static void main(String args[]) throws IOException 
  { 
    char c; 
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
    System.out.println("Enter characters, 'q' to quit.");
    // read characters 
    do { 
      c = (char) br.read(); 
      System.out.println(c); 
    } while(c != 'q'); 
  } 
}


However gives the error "Erroneous tree type: io.BufferedReader at io.Reader.main(Reader.java:10)"

What I have tried:

changed code several times and searched for error type
Posted
Updated 28-Apr-18 23:38pm

1 solution

See BufferedReader (Java Platform SE 7 )[^], and you will notice that it inherits java.io.Reader. So your use of io as a package name, and Reader as a class name is causing some confusion for the compiler. Do not use standard names for your own packages or classes.
 
Share this answer
 
Comments
four systems 30-Apr-18 6:12am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900