Java语言

王晓蒙

目录

  • 1 Introduction to Java
    • 1.1 Programming Languages
    • 1.2 Java Introduction
    • 1.3 JDK Installation
    • 1.4 A Simple Program
    • 1.5 Programming Style and Documentation
    • 1.6 Programming Error
    • 1.7 Programming Using Eclipse
    • 1.8 Review Questions
  • 2 Elementary Programming
    • 2.1 Identifiers, Variables and Constants
    • 2.2 Input By Console
    • 2.3 Numeric Data Type and Literals
    • 2.4 Augmented Numeric Operators
    • 2.5 Numeric Type Conversions
    • 2.6 Mathematical Methods
    • 2.7 Character Data Type
    • 2.8 Using String Type
    • 2.9 Console Formatting Output
  • 3 Selections
    • 3.1 Boolean and Relational Operators
    • 3.2 if-else
    • 3.3 Logical Operators
    • 3.4 switch
  • 4 Loops
    • 4.1 while
    • 4.2 Case: Guessing Numbers
    • 4.3 do-while
    • 4.4 for
    • 4.5 Nested Loops
    • 4.6 break and continue
    • 4.7 Case: Checking Palindromes
  • 5 Methods
    • 5.1 Defining and Calling a Method
    • 5.2 Passing Arguments By Values
    • 5.3 Modularizing Code
    • 5.4 Overloading Methods
    • 5.5 Variables Scope
  • 6 Arrays
    • 6.1 Array Basics
    • 6.2 Case: Analyzing Numbers
    • 6.3 Copying Arrays
    • 6.4 Passing Arrays to Methods
    • 6.5 Variable-Length Arguments List
    • 6.6 The Arrays Class
    • 6.7 Two-Dimensional Arrays Basics
    • 6.8 Two-Dimensional Arrays Processing
    • 6.9 Multidimensional Arrays
  • 7 Objects and Classes
    • 7.1 Introduction to OOP
    • 7.2 Defining Classes and Creating Objects
    • 7.3 Constructors
    • 7.4 Reference Variables and Reference Types
    • 7.5 Using Java Library
    • 7.6 Static Members
    • 7.7 Visibility Modifers
    • 7.8 Passing Objects to Methods
    • 7.9 This Keyword
    • 7.10 Wrapper Class
    • 7.11 Immutable and Interned Strings
  • 8 Inheritance and Polymorphism
    • 8.1 Super-classes and Sub-classes
    • 8.2 super Keyword and Constructor Chaining
    • 8.3 Overriding
    • 8.4 Polymorphism
    • 8.5 Objects Casting
    • 8.6 The method equals
    • 8.7 The protected Members
  • 9 Abstract Classes and Interfaces
    • 9.1 Abstract Classes
    • 9.2 Interfaces
    • 9.3 Comparable Interface
  • 10 Exception Handling
    • 10.1 Introduction
    • 10.2 Exception Declaring and Throwing
    • 10.3 Exception Catching and Handling
    • 10.4 finally
  • 11 I/O Operation
    • 11.1 I/O Introduction
    • 11.2 Binary Input
    • 11.3 Binary Output
    • 11.4 Text Input
    • 11.5 Text Output
  • 12 JavaFX Basics
    • 12.1 A Basic JavaFX Program
    • 12.2 Node Types
    • 12.3 Property Binding
    • 12.4 Node Style
    • 12.5 Layout
    • 12.6 JavaFX and Eclipse
  • 13 Event-Driven Programming
    • 13.1 Event-Source, Event and Event-Handler
    • 13.2 Defining Event-Handler Using Inner-Class
    • 13.3 Event Handling Using Lambda Expression
  • 14 Others
Programming Languages

Basic Concepts and Terms

A computer's native language, which differs among different types of computers, is its machine language—a set of built-in primitive instructions.(机器语言是计算机硬件设计过程中就确立下来的原始指令集,是机器可以直接读懂的指令,每种类型的计算机采用的指令集可能不同,例如Intel构架采用的复杂指令集X86,ARM构架采用的精简指令集等)

Assembly language uses a short descriptive word, known as a mnemonic, to represent each of the machine-language instructions.(汇编语言采用便于记忆的助记符代替机器语言中的操作码,使得代码便于理解和记忆;然而,机器是读不懂汇编语言的,因此需要一个翻译,这个翻译就是汇编器Assembler,汇编器将机器码转换为目标机器的机器码,然后执行)

High-level languages are English-like and platform independent. (高级编程语言近似人类语言英语,学习起来更容易,例如if语句直接对应英语的如果怎么样就怎么样;高级编程语言是平台独立的,也就是说理论上在任何计算机都能使用某一种高级语言,只要这类计算机有该类语言的编译器;计算机也是不能直接读懂高级语言的,需要进行编译或解释,因此又分为解释型语言和编译型语言)

An interpreter reads one statement from the source code, translates it to the machine code or virtual machine code, and then executes it right away. (解释型语言是一边解释一边执行,解释器将读到的源代码转换为机器码或则虚拟机代码进行执行,常见的有Python、JavaScript、PHP等)

A compiler translates the entire source code into a machine-code file, and the machine-code file is then executed.(编译型语言编写的源代码由编译器编译成目标机器的机器码,然后执行程序,注意这里是目标机器的机器码,比如中文翻译成英国的英语和法国的法语,这里目标对象不一样,翻译后的语言也不一样)

Java实际上不是纯粹的编译型语言或解释型语言,它是先由编译器将源代码编译为字节码文件,再由虚拟机解释执行。


TIOBE Index

https://www.tiobe.com/tiobe-index/