java---try ---catch--finally
2012-11-23 23:57
661 查看
package hello; import java.io.IOException; public class hello { int count = 0; public void check() throws IOException { byte[] str = new byte[20]; System.in.read(str); for (int i = 0; i < str.length - 1; i++) { if (str[i] == 'Z') { count++; } } if(count>0) { throw new IOException("按下了Z键"); } } public static void main(String args[]) { hello ts =new hello(); System.out.println("请输入你想输入的字符串:"); try { ts.check(); return; } catch (IOException ie) { ie.printStackTrace(); }finally { System.out.println("z is "); System.out.print(ts.count); } } }
相关文章推荐
- Java含有return 的try catch finally的执行顺序
- java try{}catch{}finally{}中catch中存在return,finally运行时间
- Java的异常处理——try-catch-finally-throw-throws
- Java异常处理中try,catch,finally的各种组合用法
- Java try catch throw exception 和 finally用法举例详解
- java try、catch、finally及finally执行顺序详解
- Java异常处理中try,catch,finally的各种组合用法
- java中关于try、catch、finally中的细节分析
- java个人学习笔记14(Error+Exception+try_catch_finally+throw+throws)
- Java try catch finally 虚拟机执行流程详解
- Java中的try catch finally
- Java中关于try、catch、finally中的细节分析
- java中关于try、catch、finally中的细节分析
- java 异常捕捉 ( try catch finally ) 深度解析
- java-基础-try、catch和finally
- java:异常处理机制 try-catch-throw-finally
- Java中finally语句块的深度解析(try catch finally的执行顺序)
- Java 异常: try...catch...finally
- Java中Try/catch/finally
- java中try catch finally与return的执行顺序