Skip to content

Commit 90fa087

Browse files
authored
Merge pull request RunestoneInteractive#11 from peterstory/fixing-references
Fixing references
2 parents 3a796d0 + f9a9d55 commit 90fa087

5 files changed

Lines changed: 47 additions & 44 deletions

File tree

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,60 @@
1+
.. _Common Mistakes:
2+
13
Common Mistakes
24
===============
35

6+
Forgetting to declare your variables
7+
------------------------------------
48

5-
- **Forgetting to declare your variables.**
6-
7-
::
9+
::
810

9-
Histo.java:21: cannot find symbol
10-
symbol : variable count
11-
location: class Histo
12-
count = new ArrayList<Integer>(10);
13-
^
11+
Histo.java:21: cannot find symbol
12+
symbol : variable count
13+
location: class Histo
14+
count = new ArrayList<Integer>(10);
15+
^
1416

15-
- **Not importing a class**:
17+
Not importing a class
18+
---------------------
1619

17-
::
20+
::
1821

19-
Histo.java:9: cannot find symbol
20-
symbol : class Scanner
21-
location: class Histo
22-
Scanner data = null;
23-
^
22+
Histo.java:9: cannot find symbol
23+
symbol : class Scanner
24+
location: class Histo
25+
Scanner data = null;
26+
^
2427

25-
- **Forgetting to use the new keyword to create an object.** Here’s
26-
an example of the error message that occurs when you forget to
27-
use the new keyword. Notice that the message is pretty unhelpful.
28-
Java *thinks* you are trying to call the Method Scanner, but
29-
there are two problems. First Scanner is not really a method it
30-
is a constructor.:
28+
Forgetting to use the new keyword to create an object
29+
-----------------------------------------------------
30+
Here’s an example of the error message that occurs when you forget to
31+
use the new keyword. Notice that the message is pretty unhelpful.
32+
Java *thinks* you are trying to call the Method Scanner, but
33+
there are two problems. First Scanner is not really a method it
34+
is a constructor.:
3135

32-
::
36+
::
3337

34-
Histo.java:14: cannot find symbol
35-
symbol : method Scanner(java.io.File)
36-
location: class Histo
37-
data = Scanner(new File("test.dat"));
38-
^
38+
Histo.java:14: cannot find symbol
39+
symbol : method Scanner(java.io.File)
40+
location: class Histo
41+
data = Scanner(new File("test.dat"));
42+
^
3943

40-
- **Forgetting a Semicolon**:
44+
Forgetting a Semicolon
45+
----------------------
4146

42-
::
47+
::
4348

44-
Histo.java:19:
45-
';' expected
46-
System.exit(0);
47-
^
49+
Histo.java:19:
50+
';' expected
51+
System.exit(0);
52+
^
4853

49-
- Forgetting to declare the kind of object in a container.:
54+
Forgetting to declare the kind of object in a container
55+
-------------------------------------------------------
5056

51-
::
57+
::
5258

53-
Note: Histo.java uses unchecked or unsafe operations. Note:
54-
Recompile with -Xlint:unchecked for details.
59+
Note: Histo.java uses unchecked or unsafe operations. Note:
60+
Recompile with -Xlint:unchecked for details.

‎_sources/Java4Python/conditionals.rst‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,6 @@ alternative then the program would print(out both A and B.)
181181
Boolean Operators
182182
-----------------
183183

184-
{sub:boolean\_operators}
185-
186184
The conditionals used in the if statement can be boolean variables,
187185
simple comparisons, and compound boolean expressions.
188186

‎_sources/Java4Python/firstjavaprogram.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ not worry! An important skill for a computer scientist is to learn what
4545
to ignore and what to look at carefully. You will soon find that there
4646
are some elements of Java that will fade into the background as you
4747
become used to seeing them. One thing that will help you is to learn a
48-
little bit about Java [sec:naming\_conventions] {Naming Conventions}.
48+
little bit about Java :ref:`Naming Conventions`.
4949

5050
The first question you probably have about this little program is “How
5151
do I run it?” Running a Java program is not as simple as running a
@@ -70,7 +70,7 @@ The command ``javac`` compiles our java source code into compiled byte
7070
code and saves it in a file called ``Hello.class``. ``Hello.class`` is a
7171
binary file so you won’t learn much if you try to examine the class file
7272
with an editor. Hopefully you didn’t make any mistakes, but if you did
73-
you may want to consult the [sec:common\_mistakes] {Common Mistakes}
73+
you may want to consult the :ref:`Common Mistakes`
7474
section for helpful hints on compiler errors.
7575

7676
Now that we have compiled our java source code we can run the compiled

‎_sources/Java4Python/javadatatypes.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ variable. If you have ever tried to use a Python variable that you have
176176
not initialized the second error message will be familiar to you. The
177177
difference here is that we see the message before we ever try to test
178178
our program. More common error messages are discussed in the section
179-
[sec:common\_mistakes] {Common Mistakes}.
179+
:ref:`Common Mistakes`.
180180

181181
The general rule in Java is that you must decide what kind of an object
182182
your variable is going to reference and then you must declare that

‎_sources/Java4Python/namingconventions.rst‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
.. _Naming Conventions:
12

23
Naming Conventions
34
==================
45

5-
{sec:naming\_conventions}
6-
76
Java has some very handy naming conventions.
87

98
- Class names always start with an upper case letter. For example,

0 commit comments

Comments
 (0)