number (2)变量相关错误

变量没有被定义

fw cannot be resolved

变量没有被初始化

正确代码

package com.itheima_01;

import java.io.FileWriter;
import java.io.IOException;

public class ExceptionDemo1 {
public static void main(String[] args) {
FileWriter fw=null;
try {
fw =new FileWriter("a.txt");
fw.write("hello");

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
try {
fw.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}

 

posted @ 2018-10-20 12:47  ThisCall  阅读(162)  评论(0编辑  收藏  举报