Think Java: How to Think Like a Computer Scientist

Think Java

How to Think Like a Computer Scientist

2nd Edition, Version 7.1.0

Think Java

How to Think Like a Computer Scientist

2nd Edition, Version 7.1.0

Allen B. Downey and Chris Mayfield Green Tea Press

Needham, Massachusetts

Copyright ? 2020 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 4.0 International License, which is available at licenses/by-nc-sa/4.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 and .

Contents

Preface

xv

1 Computer Programming

1

1.1 What Is a Computer? . . . . . . . . . . . . . . . . . . . . . . 1

1.2 What Is Programming? . . . . . . . . . . . . . . . . . . . . . 2

1.3 The Hello World Program . . . . . . . . . . . . . . . . . . . 3

1.4 Compiling Java Programs . . . . . . . . . . . . . . . . . . . 5

1.5 Displaying Two Messages . . . . . . . . . . . . . . . . . . . . 6

1.6 Formatting Source Code . . . . . . . . . . . . . . . . . . . . 7

1.7 Using Escape Sequences . . . . . . . . . . . . . . . . . . . . 9

1.8 What Is Computer Science? . . . . . . . . . . . . . . . . . . 10

1.9 Debugging Programs . . . . . . . . . . . . . . . . . . . . . . 11

1.10 Vocabulary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2 Variables and Operators

17

2.1 Declaring Variables . . . . . . . . . . . . . . . . . . . . . . . 17

2.2 Assigning Variables . . . . . . . . . . . . . . . . . . . . . . . 18

2.3 Memory Diagrams . . . . . . . . . . . . . . . . . . . . . . . . 19

2.4 Printing Variables . . . . . . . . . . . . . . . . . . . . . . . . 21

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

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

Google Online Preview   Download