Chapter 3. Fundamental Programming Structures in Java

来源:互联网 发布:b2b用什么软件优化 编辑:程序博客网 时间:2024/06/06 15:29

Chapter 3. Fundamental Programming Structures in Java

3 Java基本编程结构

·         A Simple Java Program 一个简单的Java程序

·         Comments 注释

·         Data Types 数据类型

·         Variables 变量

·         Operators 操作

·         Strings

·         Input and Output 输入和输出

·         Control Flow 控制流

·         Big Numbers 大数

·         Arrays 数组

At this point, we are assuming that you successfully installed the JDK and were able to run the sample programs that we showed you in Chapter 2. It's time to start programming. This chapter shows you how the basic programming concepts such as data types, branches, and loops are implemented in Java.

在这里,我们假定你已经成功安装了JDK并且能够运行我们在第2章提到过的那些示例程序。现在开始编程了。这一章将向你展示一些Java编程的基本概念,例如:数据类型、分支和循环的实现。

Unfortunately, in Java you can't easily write a program that uses a GUI—you need to learn a fair amount of machinery to put up windows, add text boxes and buttons that respond to them, and so on. Because introducing the techniques needed to write GUI-based Java programs would take us too far away from our goal of introducing the basic programming concepts, the sample programs in this chapter are "toy" programs, designed to illustrate a concept. All these examples simply use a shell window for input and output.

不幸的是,在Java中你无法方便的写出使用GUI的程序——你需要学习相当数量的方法去生成窗口、添加文字框和按钮,并且响应它们等等。因为介绍基于GUIJava编程技术会使我们离介绍基本编程概念的目的越来越远,所以这一章的示例程序简单得看起来就像“玩具”一样,仅仅是为了阐明某个概念。所有这些例子都简单的使用一个Shell窗口用来输入输出。

Finally, if you are an experienced C++ programmer, you can get away with just skimming this chapter: concentrate on the C/C++ notes that are interspersed throughout the text. Programmers coming from another background, such as Visual Basic, will find most of the concepts familiar and all of the syntax very different—you should read this chapter very carefully.

最后,如果你是个有经验的C++程序员,你就可以只汲取这一章的精华:把注意力集中在分布于文章中的“C++ Notes”。从Visual Basic 等其它语言转过来的程序员会发现大部分基本概念比较熟悉,但语法却有很大不同——你最好非常仔细的读一读这一章。