⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 net2.java

📁 java网络编程
💻 JAVA
字号:
package net;
/*第2题*/
 class DoException {
    public static void doTask() {
        try {
            generateException();
        }catch(MyException e){            
        }
    }
    
    public static void generateException() throws MyException{
        try{
            int a[] = {1,6,3,5,8,7,4,2,1};
            int beginCode = 'A';
            String s = "";
            for (int i = 0; i < 26; i++) {
                s += (char) (beginCode + i);
                System.out.print(" "+s.charAt(i));            
            }
            int position=0,flag=0;
            for (;;) {
            
                System.out.print(" "+s.charAt(position));                
                position=a[position];
                if(position==1)flag++;
                if(flag==2) throw  new MyException();
               }
        }//catch(MyException e1){System.out.print("ERROR!");}
        catch (Exception e){ e.printStackTrace();
            
        }
        
    }
}

class MyException extends Exception
{
	public MyException()
	{
	 System.out.print("程序停止!");
	
	}
}

public class Net2 {
	public  static void main(String args[])
	{
		
		DoException nt=new DoException();
		nt.doTask();
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -