第一章 计算机、程序和Java概述 课本源代码

//程序清单1-1 Welcome-java
public class Welcome
{
	public static void main(String[] args)
	{
		//Display message Welcome t java ! to the console
		System.out.println("Welcome to Java!");
	}

}

//程序清单1-2 welcome1.java
public class Welcome1
{
	public static void main(String[] args)
	{
		System.out.println("Programming is fun!");
		System.out.println("Fundamentals First");
		System.out.println("Problem Driven");
	}
}

//程序清单1-3 ComputeExpression.java
public class ComputeExperssion 
{
	public static void main(String[] args)
	{
		System.out.println((10.5+2*3)/(45-3.5));
	}
}


//程序清单1-4 WelcomeInMessageDialogBox.java
/* This application program displays Welcome to Java!
 * in a message dialog box
 * 功能:在对话框中输出“welcome to Java!"
 */
 import javax.swing.JOptionPane;

 public class WelcomeInMessageDialogBox
 {
	 public static void main(String [] args)
	 {
		 //输出“Welcome to Java”
		 JOptionPane.showMessageDialog(null,"Welcome to Java!");
	 }
 }

posted on 2012-04-24 17:53  1.曲待续  阅读(190)  评论(0编辑  收藏  举报

导航