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();
           	 
        }
    	
    	
    	
    	    }
    		} 
    }
    

      

  • 相关阅读:
    《Google 软件测试之道》摘录
    UIRecorder环境搭建及录制实现
    网易《人性的哲学与科学》笔记
    网易《公正:该如何做是好?》笔记(不定时更新)
    自助饮料机实现
    网易《社会心理学》笔记(不定时更新)
    uiautomator +python 安卓UI自动化尝试
    doc
    doc
    doc
  • 原文地址:https://www.cnblogs.com/zhangnaitao/p/5901878.html
Copyright © 2011-2022 走看看