+ -
当前位置:首页 → 问答吧 → cannot not find symbol

cannot not find symbol

时间:2011-12-23

来源:互联网

1
2
3
4
5
6
 public static void main(String[] args) throws IOException{ // TODO code application logic here do{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); }while("y".equals((br.readLine().toLowerCase()))); }


请问为什么while()里面就看不到br呢?

作者: TIDUS30536   发布时间: 2011-12-23

你的
BufferedReader 是区域变数
{
区域变数---可视范围
}
1
2
3
4
5
6
7
8
9
10
11
12
public static void main(String[] args) throws IOException{ try { BufferedReader br = null; do{
       br = new BufferedReader(new InputStreamReader(System.in));
       }while("y".equals((br.readLine().toLowerCase())));
    }
    catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
}

作者: pclevin   发布时间: 2011-12-23