public boolean save(String filename){ /* * 保存文件 */ try{ File file = new File(path + filename); ... // 未产生异常 return true; } catch (FileNotFoundException e){ // 产生异常 return false; } }
public void save(String filename) throws FileNotFoundException{ File file = new File(path + filename); ... }
public class Test { private String name; private class Test1{ public void sayHello(){ System.out.println("Hello, My name is " + name); // 会报错 } } }
public class Test { private final String name; // 加上了 final 关键字修饰 private class Test1{ public void sayHello(){ System.out.println("Hello, My name is " + name); } } }
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/gulu_gulu_jp/article/details/46929851