Skip to content

Commit 6cff0f3

Browse files
committed
added many index terms
1 parent e2c0678 commit 6cff0f3

18 files changed

+148
-27
lines changed

appa.tex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ \section{DrJava interactions}
7171
It provides the ability to try out code quickly, without having to write a class definition and save/compile/run the program.
7272
Figure~\ref{fig.drjava2} shows an example.
7373

74+
\index{interactions}
75+
7476
\begin{figure}[!ht]
7577
\begin{center}
7678
\includegraphics[width=\textwidth]{figs/drjava-logic.png}
@@ -125,6 +127,8 @@ \section{Command-line interface}
125127
\section{Command-line testing}
126128
\label{cltesting}
127129

130+
\index{testing}
131+
128132
As described in Section~\ref{sec:examples}, it's more effective to program and debug your code little by little than to attempt writing everything all at once.
129133
And after you've completed programming an algorithm, it's important to test that it works correctly on a variety of inputs.
130134

@@ -165,6 +169,7 @@ \section{Command-line testing}
165169
\end{enumerate}
166170

167171
\index{redirection operator}
172+
\index{operator!redirection}
168173
\index{System.in}
169174
\index{System.out}
170175

@@ -284,6 +289,8 @@ \section{Tracing with a debugger}
284289
\end{center}
285290
\end{figure}
286291

292+
\index{tracing}
293+
287294
To the right are several buttons that allow you to step through the code at your own pace.
288295
You can also press {\sf Automatic Trace} to watch DrJava run your code one line at a time.
289296

appb.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ \section{Example source file}
250250
So we use a multi-line comment (\java{/*}).
251251
Our example source file, {\tt Convert.java}, includes the MIT License (\url{https://opensource.org/licenses/MIT}).
252252

253+
\index{Convert.java}
254+
253255
\begin{scriptsize}
254256
\begin{code}
255257
/*
@@ -369,6 +371,8 @@ \section{Example source file}
369371

370372
\begin{enumerate}
371373

374+
\index{command-line interface}
375+
372376
\item From the command line, go to the location for {\tt Convert.java}.
373377
The {\tt -d} option of {\tt javadoc} indicates where to generate the HTML files.
374378

appd.tex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ \subsubsection*{Flow of execution}
247247
\label{flowexec}
248248

249249
\index{flow of execution}
250+
\index{tracing}
250251

251252
If you are not sure how the flow of execution is moving through your program, add print statements to the beginning of each method with a message like ``entering method foo'', where \java{foo} is the name of the method.
252253
Now when you run the program, it displays a trace of each method as it is invoked.
@@ -319,6 +320,8 @@ \subsection*{I added so many print statements I get inundated with output.}
319320
For example, if you are sorting an array, sort a {\em small} array.
320321
If the program takes input from the user, give it the simplest input that causes the error.
321322

323+
\index{nested}
324+
322325
Also, clean up the code.
323326
Remove unnecessary or experimental parts, and reorganize the program to make it easier to read.
324327
For example, if you suspect that the error is in a deeply-nested part of the program, rewrite that part with a simpler structure.

appe.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ \section{Unreachable code}
2525
As soon as either of them executes, the method terminates without executing any more statements.
2626

2727
\index{dead code}
28+
\index{unreachable}
2829

2930
Code that appears after a \java{return} statement (in the same block), or any place else where it can never be executed, is called {\bf dead code}.
3031
The compiler will give you an ``unreachable statement'' error if part of your code is dead.

ch01.tex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ \section{The hello world program}
9191
% more precise, but also to reduce the number of times ``print'' appears,
9292
% which is a lot!
9393

94+
\index{Hello.java}
95+
9496
% height = 130 + 15 * num_lines
9597
\begin{trinket}[235]{Hello.java}
9698
public class Hello {
@@ -119,8 +121,8 @@ \section{The hello world program}
119121
%In fact, we won't be able to explain all of them for several more chapters.
120122
%But we can start with the structure.
121123

122-
\index{class!definition}
123-
\index{method!definition}
124+
\index{class!declaration}
125+
\index{method!declaration}
124126
\index{statement}
125127
\index{print statement}
126128

@@ -297,6 +299,8 @@ \section{Displaying two messages}
297299
\java{System.out.println} appends a special character, called a {\bf newline}, that moves to the beginning of the next line.
298300
If you don't want a newline at the end, you can use \java{print} instead of \java{println}:
299301

302+
\index{Goodbye.java}
303+
300304
\begin{trinket}[235]{Goodbye.java}
301305
public class Goodbye {
302306

@@ -367,6 +371,7 @@ \section{Formatting source code}
367371
%However, with that freedom comes responsibility, both to yourself (when you look at the code in the future) and others who will be reading, understanding, and debugging it.
368372

369373
\index{Google style}
374+
\index{style guide}
370375

371376
Organizations that do a lot of software development usually have strict guidelines on how to format source code.
372377
For example, Google publishes its Java coding standards for use in open-source projects: \url{https://google.github.io/styleguide/javaguide.html}.

ch02.tex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ \section{Rounding errors}
430430
%Even with double-precision, you will frequently run into problems.
431431

432432
\index{rounding error}
433+
\index{error!rounding}
433434
\index{arithmetic!floating-point}
434435

435436
The difference between the number we want and the floating-point number we get is called {\bf rounding error}.
@@ -651,6 +652,8 @@ \section{Other types of errors}
651652
Instead, it will do exactly what you told it to do.
652653
For example, here is a version of the hello world program with a logic error:
653654

655+
\index{Hello.java}
656+
654657
\begin{trinket}[235]{Hello.java}
655658
public class Hello {
656659

ch03.tex

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ \section{The Scanner class}
104104
The \java{Scanner} class provides a method called \java{nextLine} that reads a line of input from the keyboard and returns a \java{String}.
105105
The following example reads two lines and repeats them back to the user:
106106

107+
\index{Echo.java}
108+
107109
\begin{trinket}{Echo.java}
108110
import java.util.Scanner;
109111

@@ -135,6 +137,8 @@ \section{The Scanner class}
135137

136138
\section{Language elements}
137139

140+
\index{language!elements}
141+
138142
At this point, we have seen nearly all of the organizational units that make up Java programs.
139143
Figure~\ref{fig.package} shows how these ``language elements'' are related.
140144

@@ -163,7 +167,6 @@ \section{Language elements}
163167
Knowing this terminology is helpful, because error messages often say things like ``not a statement'' or ``illegal start of expression'' or ``unexpected token''.
164168
Comparing Java to English, statements are complete sentences, expressions are phrases, and tokens are individual words and punctuation marks.
165169

166-
167170
Note there is a big difference between the Java {\em language}, which defines the elements in Figure~\ref{fig.package}, and the Java {\em library}, which provides the built-in classes that you can import.
168171
For example, the keywords \java{public} and \java{class} are part of the Java language, but the names \java{PrintStream} and \java{Scanner} are not.
169172

@@ -356,7 +359,7 @@ \section{Formatting output}
356359
However when you run the program, it will display:
357360

358361
\index{MissingFormatArgumentException}
359-
\index{run-time error}
362+
\index{exception!MissingFormatArgument}
360363

361364
\begin{small}
362365
\begin{stdout}
@@ -449,6 +452,7 @@ \section{Remainder operator}
449452
\index{modulo}
450453
\index{\% operator}
451454
\index{operator!remainder}
455+
\index{remainder}
452456

453457
We have already seen the division operation (\java{/}), which computes the quotient of two numbers.
454458
If the numbers are integers, it performs integer division.
@@ -465,6 +469,8 @@ \section{Remainder operator}
465469
The second line, which is pronounced ``76 mod 12'', yields 4.
466470
So 76 inches is 6 feet, 4 inches.
467471

472+
\index{modulus}
473+
468474
Many people (and textbooks) incorrectly refer to \java{\%} as the ``modulus operator''.
469475
In mathematics, however, {\bf modulus} is the number you're dividing by.
470476
In the previous example, the modulus is 12.
@@ -493,6 +499,8 @@ \section{Putting it all together}
493499
%Since we've looked at each of these topics in isolation, it's important to see how they fit together in a complete program.
494500
%If you've been working through the examples on your computer as you've been reading (like we recommended in Section~\ref{sec:examples}), then good job!
495501

502+
\index{Convert.java}
503+
496504
\begin{trinket}{Convert.java}
497505
import java.util.Scanner;
498506

@@ -765,6 +773,8 @@ \section{Exercises}
765773
To choose a random number, you can use the \java{Random} class in \java{java.util}.
766774
Here's how it works:
767775

776+
\index{GuessStarter.java}
777+
768778
\begin{trinket}{GuessStarter.java}
769779
import java.util.Random;
770780

ch04.tex

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ \section{Chaining and nesting}
211211
The first branch contains a \java{print} statement, and the second branch contains another conditional statement, which has two branches of its own.
212212
These two branches are also \java{print} statements, but they could have been conditional statements as well.
213213

214+
\index{nested!conditions}
215+
214216
These kinds of nested structures are common, but they can become difficult to read very quickly.
215217
Good indentation is essential to make the structure (or intended structure) apparent to the reader.
216218

@@ -330,6 +332,7 @@ \section{De Morgan's laws}
330332
\section{Boolean variables}
331333

332334
\index{expression!boolean}
335+
\index{type!boolean}
333336

334337
To store a \java{true} or \java{false} value, you need a \java{boolean} variable.
335338
You can declare and assign them like other variables.
@@ -535,8 +538,8 @@ \section{Validating input}
535538
What if the user doesn't enter a number at all?
536539
What would happen if they typed the word ``hello'', either on accident or on purpose?
537540

538-
\index{exception!InputMismatch}
539541
\index{InputMismatchException}
542+
\index{exception!InputMismatch}
540543

541544
\begin{small}
542545
\begin{stdout}
@@ -549,6 +552,7 @@ \section{Validating input}
549552
\end{small}
550553

551554
\index{run-time error}
555+
\index{testing}
552556

553557
If the user inputs a \java{String} when we expect a \java{double}, Java reports an ``input mismatch'' exception.
554558
We can prevent this run-time error from happening by testing the input first.
@@ -589,6 +593,8 @@ \section{Example program}
589593
In this chapter we have seen relational and logical operators, \java{if} statements, the \java{Math} class, and validating input.
590594
The following program shows how the individual code examples in the last section fit together.
591595

596+
\index{Logarithm.java}
597+
592598
\begin{trinket}{Logarithm.java}
593599
import java.util.Scanner;
594600

@@ -639,11 +645,9 @@ \section{Vocabulary}
639645
\term{boolean}
640646
A data type with only two possible values, \java{true} and \java{false}.
641647

642-
\index{operator!relational}
643648
\term{relational operator}
644649
An operator that compares two values and produces a \java{boolean} indicating the relationship between them.
645650

646-
\index{statement!conditional}
647651
\term{conditional statement}
648652
A statement that uses a condition to determine which statements to execute.
649653

@@ -660,7 +664,6 @@ \section{Vocabulary}
660664
\term{nesting}
661665
Putting a conditional statement inside one or both branches of another conditional statement.
662666

663-
\index{operator!logical}
664667
\term{logical operator}
665668
An operator that combines boolean values and produces a boolean value.
666669

ch05.tex

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ \chapter{Methods and testing}
1212
\section{Defining new methods}
1313
\label{adding_methods}
1414

15-
\index{method!definition}
15+
\index{method!declaration}
1616

1717
%You have probably guessed by now that you can define more than one method in a class.
1818

@@ -22,6 +22,8 @@ \section{Defining new methods}
2222
Java uses the keyword \java{void} to define such methods.
2323
Here's a simple example:
2424

25+
\index{NewLine.java}
26+
2527
\begin{trinket}[310]{NewLine.java}
2628
public class NewLine {
2729

@@ -120,6 +122,7 @@ \section{Defining new methods}
120122

121123

122124
\section{Flow of execution}
125+
123126
\index{flow of execution}
124127

125128
When you look at a class definition that contains several methods, it is tempting to read it from top to bottom.
@@ -162,6 +165,8 @@ \section{Parameters and arguments}
162165
When you define a method, you name the {\bf parameters}, which are variables that indicate what arguments are required.
163166
The following class shows an example:
164167

168+
\index{PrintTwice.java}
169+
165170
\begin{trinket}[295]{PrintTwice.java}
166171
public class PrintTwice {
167172

@@ -277,6 +282,8 @@ \section{Parameters and arguments}
277282

278283
Pulling together the code fragments, here is the complete program:
279284

285+
\index{PrintTime.java}
286+
280287
\begin{trinket}[340]{PrintTime.java}
281288
public class PrintTime {
282289

@@ -340,6 +347,7 @@ \section{Stack diagrams}
340347
%Stack diagrams help you to visualize the {\bf scope} of a variable, which is the area of a program where a variable exists.
341348

342349
\index{Java Tutor}
350+
\index{tracing}
343351

344352
Stack diagrams are a good mental model for how variables and methods work at run-time.
345353
Learning to trace the execution of a program on paper (or on a whiteboard) is a useful skill for communicating with other programmers.
@@ -483,6 +491,8 @@ \section{Incremental development}
483491
The return statement is a placeholder that is only necessary for the program to compile.
484492
At this stage the program doesn't do anything useful, but it is good to compile it so we can find any syntax errors before we add more code.
485493

494+
\index{testing}
495+
486496
It's usually a good idea to think about testing {\em before} you develop new methods; doing so can help you figure out how to implement them.
487497
To test the method, we can invoke it from \java{main} using the sample values:
488498

ch06.tex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ \section{The for statement}
231231
\section{Nested loops}
232232
\label{nested}
233233

234+
\index{loop!nested}
235+
\index{nested!loops}
236+
234237
Like conditional statements, loops can be nested one inside the other.
235238
Nested loops allow you to iterate over two variables.
236239
For example, we can generate a ``multiplication table'' like this:
@@ -446,6 +449,9 @@ \section{The indexOf method}
446449
To visualize how \java{indexOf} and other \java{String} methods work, it helps to draw a picture like Figure~\ref{fig.banana}.
447450
The previous code starts at index 2 (the first \java{'n'}) and finds the next \java{'a'}, which is at index 3.
448451

452+
\index{memory diagram}
453+
\index{diagram!memory}
454+
449455
\begin{figure}[!ht]
450456
\begin{center}
451457
\includegraphics{figs/banana.pdf}
@@ -477,6 +483,7 @@ \section{String comparison}
477483
\label{strcmp}
478484

479485
\index{equals}
486+
\index{string!comparing}
480487

481488
To compare two strings, it may be tempting to use the \java{==} and \java{!=} operators.
482489

0 commit comments

Comments
 (0)