You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.markdown
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ A compendium for self-education about "data structures and algorithms," created
6
6
1.[How to use this repository](#how-to-use-this-repository)
7
7
1.[Running the code](#running-the-code)
8
8
*[JavaScript](#javascript)
9
+
*[Java](#java)
9
10
*[PHP](#php)
10
11
*[Perl](#perl)
11
12
*[Python](#python)
@@ -68,6 +69,42 @@ Alternatively, open the `.html` file in your web browser (probably just by doubl
68
69
*[Set a breakpoint - Firefox Developer Tools](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Set_a_breakpoint)
69
70
*[Step through code - Firefox Developer Tools](https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Set_a_breakpoint)
70
71
72
+
#### [Java](https://java.com/)
73
+
74
+
The Java code samples are all compatible with [Java SE](https://en.wikipedia.org/wiki/Java_Platform%2C_Standard_Edition"Java Platform, Standard Edition") 8. They must first be compiled before they can be run. To compile them, invoke the Java compiler like this at a command shell:
75
+
76
+
```sh
77
+
# to compile the recursive implementation of the binary search example
78
+
javac binary_search/BinarySearchRecursive.java
79
+
```
80
+
81
+
Once compiled, the code samples can be run by informing the Java application launcher where to find them, and which class's code to execute. Do so like this:
# Tell Java to look for Name of the class whose `main()`
87
+
# compiled code (`.class`) method should be executed.
88
+
# files in the
89
+
# following directory.
90
+
```
91
+
92
+
Java's standard debugger is called `jdb` (on both [macOS/*nix](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jdb.html) and [Windows](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jdb.html)). To debug the Java code samples, first compile them with the `-g` option to include debugging information:
93
+
94
+
```sh
95
+
javac -g binary_search/BinarySearchRecursive.java
96
+
# ^^
97
+
# Make sure you include this `-g` switch!
98
+
```
99
+
100
+
Once compiled with debugging information included, you can use the Java debugger to inspect the values of all variables during program exeuction, run the code one line at a time, step by step, and more:
Once in the debugger, type `help` to get help. (The `jdb` help is pretty thorough but can be terse, so feel free to hop into the [Better Angels's public chat room](https://gitter.im/betterangels/better-angels) if you need help from a human.)
107
+
71
108
#### [PHP](https://php.net/)
72
109
73
110
The PHP code samples are all compatible with PHP 5.6 and newer. To run them, execute them like this at a command shell:
@@ -141,6 +178,7 @@ You can use the debugger to run one line of code at a time, and it will allow yo
141
178
In addition to containing detailed inline code comments, each example is also formally documented using the best practices of the language in which the example code is written. Formal documentation means that the files, classes, class members, methods, functions, arguments of each function, and other relevant implementation details are accessible by tools that automatically generate a programmer's manual for how to use the class, method, or function implemented by the example. Each language has its own de-facto standard tool for this:
142
179
143
180
*[JSDoc](http://usejsdoc.org/) is used for documenting the JavaScript code samples.
181
+
*[Javadoc](https://docs.oracle.com/javase/8/docs/technotes/guides/javadoc/index.html) is used for documenting the Java code samples.
144
182
*[PHPDoc](https://phpdoc.org/) is used for documenting the PHP code samples.
145
183
*[Plain Old Documentation (POD)](http://perldoc.perl.org/perlpod.html) format is used for documenting the Perl code samples.
146
184
*[Google-style Python docstrings](https://google.github.io/styleguide/pyguide.html?showone=Comments#Comments) are used for documenting the Python code samples. Additionally, the Python code samples embed [`doctest`s](https://en.wikipedia.org/wiki/Doctest) to show example usage and output.
0 commit comments