thinkjava.pdf

(1366 KB) Pobierz
Think Java
How to Think Like a Computer Scientist
Version 6.1.3
Think Java
How to Think Like a Computer Scientist
Version 6.1.3
Allen B. Downey and Chris Mayfield
Green Tea Press
Needham, Massachusetts
Copyright
©
2016 Allen B. Downey and Chris Mayfield.
Green Tea Press
9 Washburn Ave
Needham, MA 02492
Permission is granted to copy, distribute, and/or modify this work under
the terms of the Creative Commons Attribution-NonCommercial-ShareAlike
3.0 Unported License, which is available at
http://creativecommons.org/
licenses/by-nc-sa/3.0/.
A
The original form of this book is L TEX source code. Compiling this code has
the effect of generating a device-independent representation of the book, which
can be converted to other formats and printed.
A
The L TEX source for this book is available from
http://thinkjava.org.
Contents
Preface
1 The way of the program
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
1.10
What is programming? . . . . . . . . . . . . . . . . . . . . .
What is computer science? . . . . . . . . . . . . . . . . . . .
Programming languages . . . . . . . . . . . . . . . . . . . .
The hello world program . . . . . . . . . . . . . . . . . . . .
Displaying strings . . . . . . . . . . . . . . . . . . . . . . . .
Escape sequences . . . . . . . . . . . . . . . . . . . . . . . .
Formatting code . . . . . . . . . . . . . . . . . . . . . . . . .
Debugging code . . . . . . . . . . . . . . . . . . . . . . . . .
Vocabulary . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xiii
1
1
2
3
4
6
7
8
9
10
12
15
15
16
17
18
19
2 Variables and operators
2.1
2.2
2.3
2.4
2.5
Declaring variables . . . . . . . . . . . . . . . . . . . . . . .
Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . .
State diagrams
. . . . . . . . . . . . . . . . . . . . . . . . .
Printing variables . . . . . . . . . . . . . . . . . . . . . . . .
Arithmetic operators . . . . . . . . . . . . . . . . . . . . . .
Zgłoś jeśli naruszono regulamin