Java BufferedReader

旧巷老猫 提交于 2019-12-13 19:04:40

问题


I'm looking at this tutorial about BufferedReader at youtube

https://www.youtube.com/watch?v=yofFVbARIRU

I write the code exactly as he does but I can't get it to work. I cant get the BufferedReader code to work even though I imported it with

import java.io.*;

InputStreamReader stream = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader (stream);

I solved it with this code:

InputStreamReader stream = new InputStreamReader(System.in);
java.io.BufferedReader reader = new java.io.BufferedReader (stream);

And this works as well:

java.io.BufferedReader reader = 
new java.io.BufferedReader (new InputStreamReader(System.in));

Could someone explain to me what's wrong in the first code? Because it works for him who's giving the tutorial


回答1:


You've likely got your own class that you've named BufferedReader and whose name is clashing with the core class and thus confusing the Java compiler. Rename it!



来源:https://stackoverflow.com/questions/28934923/java-bufferedreader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!