Java程序的种类主要分为Java小应用程序(Java Applet)和Java应用程序(Java Application),它们各自具有不同的运行环境和特点。
1. Java小应用程序(Java Applet)是专为Web浏览器设计的,它们在用户的浏览器内嵌入Java虚拟机(Java Virtual Machine, JVM)运行。这些程序通常包含在HTML文档中,通过`<APPLET>`标签嵌入,如 `<APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25> </APPLET>`,其中`CODE`属性指定要执行的Java类文件名。Java Applet能够利用浏览器的特性与用户交互,但它们的生命周期受到浏览器控制,且受限于安全沙箱。
2. Java应用程序则是独立运行在用户机器上的,它们的主入口方法是`public static void main(String[] args)`,这意味着任何想要成为Java Application的程序都需要包含这个主函数。这类程序不受浏览器限制,可以更灵活地处理数据和执行复杂的任务。
Java Script虽然不是Java的一部分,但它是一种嵌入在HTML文件中的脚本语言,由Netscape公司引入,主要用于网页动态效果和客户端交互。与Java Applet不同,JavaScript不依赖JVM,可以直接在浏览器环境中解释执行。
学习Java语言编程,如《Java语言程序设计》一书所述,需要掌握面向对象编程的核心概念,如类、对象、继承、多态和接口等。学习过程中强调动手实践,通过编写代码理解概念,并通过分析他人的代码提升自己的编程能力。课程目标设定为入门级,要求学生掌握基本编程方法,并通过上机考试检验学习成果。
教学方法注重理论与实践相结合,鼓励学生主动预习、参与课堂讨论,认真完成实验和作业。课程内容包括Java语言概述、语法基础、面向对象特性、Applet应用、图形用户界面设计、异常处理、线程管理、集合操作以及网络编程等。
参考书籍丰富多样,包括官方教程、经典的编程思想书籍和语言规范文档,为深入学习提供了全面的资源支持。回顾历史,Java的发展起源于Sun Microsystems的“the Green Project”,最初是为了开发消费电子产品市场,随着时间的推移,Java逐渐发展成为全球范围内广泛使用的编程语言。