zoukankan      html  css  js  c++  java
  • 0923异常——练习题目作业

    package exception;
    
    public class TestException {
    		public static void main(String[] args)
    		{
    	    for(int i=0;i<4;i++)
    	    {
    	    	
    	    	
    	    	
    	    	
    	try
    	{
    				int k;
    				switch(i)
    				{           
    				case 0: int zero=0;k=911/zero;break;                     
    //            	case 1: int b[]=null;k=b[0];break;
    //           	case 2: int c[]=new int[2];k=c[9];break;
    //           	case 3: char ch="abc".charAt(99);break;
    				} 
    	} 
        catch(Exception e)
        {
        	System.out.println("分母不能为0  "+"错误提示如下");
        	e.printStackTrace();
           	 
        }
    	
    	
    	
    	    }
    		} 
    }
    

      

    package exception;
    
    public class TestException {
    		public static void main(String[] args)
    		{
    	    for(int i=0;i<4;i++)
    	    {
    	    	
    	    	
    	    	
    	    	
    	try
    	{
    				int k;
    				switch(i)
    				{           
    //				case 0: int zero=0;k=911/zero;break;                     
                	case 1: int b[]=null;k=b[0];break;
    //           	case 2: int c[]=new int[2];k=c[9];break;
    //           	case 3: char ch="abc".charAt(99);break;
    				} 
    	} 
        catch(Exception e)
        {
        	System.out.println("空指针  "+"错误提示如下");
        	e.printStackTrace();
           	 
        }
    

      

    package exception;
    
    public class TestException {
    		public static void main(String[] args)
    		{
    	    for(int i=0;i<4;i++)
    	    {
    	    	
    	    	
    	    	
    	    	
    	try
    	{
    				int k;
    				switch(i)
    				{           
    //				case 0: int zero=0;k=911/zero;break;                     
    //            	case 1: int b[]=null;k=b[0];break;
               	case 2: int c[]=new int[2];k=c[9];break;
    //           	case 3: char ch="abc".charAt(99);break;
    				} 
    	} 
        catch(Exception e)
        {
        	System.out.println("超出数组长度  "+"错误提示如下");
        	e.printStackTrace();
           	 
        }
    	
    

      

    package exception;
    
    public class TestException {
    		public static void main(String[] args)
    		{
    	    for(int i=0;i<4;i++)
    	    {
    	    	
    	    	
    	    	
    	    	
    	try
    	{
    				int k;
    				switch(i)
    				{           
    //				case 0: int zero=0;k=911/zero;break;                     
    //            	case 1: int b[]=null;k=b[0];break;
    //           	case 2: int c[]=new int[2];k=c[9];break;
               	case 3: char ch="abc".charAt(99);break;
    				} 
    	} 
        catch(Exception e)
        {
        	System.out.println("输入的字符串错误  "+"错误提示如下");
        	e.printStackTrace();
           	 
        }
    	
    	
    	
    	    }
    		} 
    }
    

      

  • 相关阅读:
    jquery选择器
    js中的闭包技术
    idea创建servlet不能创建:
    JSP页面不解析EL表达式的原因
    大对象数据LoB的应用
    缓冲流、转换流、序列化流相关流知识点
    jdk5.0新特性(注解)
    EKT相关知识(Class类对象的方法补充)
    java中调用存储过程或函数
    Java 缓冲流
  • 原文地址:https://www.cnblogs.com/zhangnaitao/p/5901878.html
Copyright © 2011-2022 走看看