Think Java: How to Think Like a Computer Scientist

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 licenses/by-nc-sa/3.0/.

The original form of this book is LATEX 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.

The LATEX source for this book is available from .

Contents

Preface

xiii

1 The way of the program

1

1.1 What is programming? . . . . . . . . . . . . . . . . . . . . . 1

1.2 What is computer science? . . . . . . . . . . . . . . . . . . . 2

1.3 Programming languages . . . . . . . . . . . . . . . . . . . . 3

1.4 The hello world program . . . . . . . . . . . . . . . . . . . . 4

1.5 Displaying strings . . . . . . . . . . . . . . . . . . . . . . . . 6

1.6 Escape sequences . . . . . . . . . . . . . . . . . . . . . . . . 7

1.7 Formatting code . . . . . . . . . . . . . . . . . . . . . . . . . 8

1.8 Debugging code . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.9 Vocabulary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

1.10 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2 Variables and operators

15

2.1 Declaring variables . . . . . . . . . . . . . . . . . . . . . . . 15

2.2 Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.3 State diagrams . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.4 Printing variables . . . . . . . . . . . . . . . . . . . . . . . . 18

2.5 Arithmetic operators . . . . . . . . . . . . . . . . . . . . . . 19

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download