學習Java09

public class Day{

	public static void main(String[] args){
		String test ="no";
		try{
			System.out.println("Start try");
			doRisky(test);
			System.out.println("end try");
			}
			catch(ScaryException se){
			System.out.println("scary exception");
			}finally{
			System.out.println("finally");
			}
			System.out.println("end of main");
			}
		static void doRisky(String test) throws ScaryException{
			System.out.println("start risky");
			if("yes".equals(test)){
			throw new ScaryException();
			}
			System.out.println("end risky");
			return;
	}
}

Exception...


the first GUI:

import javax.swing.*;
import java.awt.*;
public class Day{

	public static void main(String[] args){
		JFrame frame=new JFrame();
		JButton button =new JButton("Click hy!");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().add(button);
		frame.setSize(300,300);
		frame.setVisible(true);
	}
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章