Java 找不到符号错误bufferedreader

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24635741/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 13:35:56  来源:igfitidea点击:

Cannot find symbol error bufferedreader

java

提问by user3817065

THIS IS MY CODE

这是我的代码

 import java.IO.*; 
 class jed { 
    public static void main (String args[]){

    BufferedReader datain = new BufferedReader(new InputStreamReader(System.in));
    String name =" ";
    System.out.print("What is your name?:"); 
    try{ 
       name = datain.readline(); 
    } catch(IOException e) { 
      System.out.print("Error");
    } 

    System.out.print("Your name is" + name); } }

THIS IS THE ERROR

这是错误

 D:\>javac jed.java jed.java:1: error: package java.IO does not exist
 import java.IO.*; ^ jed.java:4: error: cannot find symbol
 BufferedReader datain = new BufferedReader(new
 InputStreamReader(System.in)); ^   symbol:   class BufferedReader  
 location: class jed jed.java:4: error: cannot find symbol
 BufferedReader datain = new BufferedReader(new
 InputStreamReader(System.in)); ^   symbol:   class BufferedReader   
 location: class jed jed.java:4: error: cannot find symbol
 BufferedReader datain = new BufferedReader(new
 InputStreamReader(System.in));^   symbol:   class InputStreamReader   
 location: class jed jed.java:10: error: cannot
 find symbol catch(IOException e){^   symbol:  class IOException                                                      location: class jed 5 errors

I will appreciate any help I can get to fix this issue. Thank you

我将不胜感激我能得到的任何帮助来解决这个问题。谢谢

回答by Damian Leszczyński - Vash

Java is case sensitive. You should import java.io.*, instead of java.IO.*.

Java 区分大小写。您应该 import java.io.*,而不是java.IO.*.

回答by JamesB

Java is case sensitive.

Java 区分大小写。

Your import is wrong. Change

你的导入是错误的。改变

import java.IO.*;

to

import java.io.*;

In defence of the compiler it does actually tell you the problem clearly:

在为编译器辩护时,它确实清楚地告诉您问题:

error: package java.IO does not exist import java.IO.*;

错误:包 java.IO 不存在 import java.IO.*;

回答by Mandeep thakur

You have to change .readline()to .readLine(), because java is case sensitive.

您必须更改.readline().readLine(),因为 java 区分大小写。