@Test
public void testReverseInPlaceFail() {
int[] input1 = { 3, 4, 5 };
ArrayExamples.reverseInPlace(input1);
assertArrayEquals(new int[] { 5, 4, 3 }, input1);
}
@Test
public void testReverseInPlacePass() {
int[] input1 = { 5, 6, 6, 5 };
ArrayExamples.reverseInPlace(input1);
assertArrayEquals(new int[] { 5, 6, 6, 5 }, input1);
}
The symptom, as the output of running the tests

The bug, as the before-and-after code change required to fix it
Before:
static void reverseInPlace(int[] arr) {
for(int i = 0; i < arr.length; i += 1) {
arr[i] = arr[arr.length - i - 1];
}
}
After:
static void reverseInPlace(int[] arr) {
for (int i = 0; i < arr.length / 2; i += 1) {
int temp = arr[i];
arr[i] = arr[arr.length - i - 1];
arr[arr.length - i - 1] = temp;
}
}
Using a temporary variable prevents the previous value of arr[i] from being lost after arr[i] is reassigned to arr[arr.length - i - 1].
Additionally, i < arr.length is changed to i < arr.length / 2 so that the pairs of elements being swapped are only swapped once instead of twice.
I am researching the command find. I found this link from redhat.com that describes some different options. I used man find to look up more details.
The working directory is the docsearch directory.
-name (Source: redhat.com)
chapter-1.txt, which is useful if you know a file name but don’t know or don’t remember where it is stored.
$ find technical -name "chapter-1.txt"
technical/911report/chapter-1.txt
Session*-PDF.txt. This is useful for finding multiple files with a similar name, or if you want to find a file and don’t remember the exact name.
$ find technical -name "Session*-PDF.txt"
technical/government/Alcohol_Problems/Session2-PDF.txt
technical/government/Alcohol_Problems/Session3-PDF.txt
technical/government/Alcohol_Problems/Session4-PDF.txt
-ls (Source: redhat.com)
government directory and associated info. It is useful for seeing file size, file permissions, owner, etc.
$ find technical/government -ls
17460172 0 drwxr-xr-x 8 sophiazhu staff 256 Feb 8 14:16 technical/government
17460173 0 drwxr-xr-x 19 sophiazhu staff 608 Feb 8 14:16 technical/government/About_LSC
17460178 16 -rwxr-xr-x 1 sophiazhu staff 7083 Feb 8 14:16 technical/government/About_LSC/LegalServCorp_v_VelazquezSyllabus.txt
17460181 96 -rwxr-xr-x 1 sophiazhu staff 47991 Feb 8 14:16 technical/government/About_LSC/Progress_report.txt
...
government directory and associated info. One thing it is useful for is seeing the permissions of each subdirectory.
$ find technical/government -type d -ls
17460172 0 drwxr-xr-x 8 sophiazhu staff 256 Feb 8 14:16 technical/government
17460173 0 drwxr-xr-x 19 sophiazhu staff 608 Feb 8 14:16 technical/government/About_LSC
17460196 0 drwxr-xr-x 16 sophiazhu staff 512 Feb 8 14:16 technical/government/Env_Prot_Agen
-type (Source: redhat.com)
government directory, which is useful if you only want the files and not the directories.
$ find technical/government -type f
technical/government/About_LSC/LegalServCorp_v_VelazquezSyllabus.txt
technical/government/About_LSC/Progress_report.txt
technical/government/About_LSC/Strategic_report.txt
technical/government/About_LSC/Comments_on_semiannual.txt
...
government directory, which is useful to see the structure of the directories.
$ find technical/government -type d
technical/government
technical/government/About_LSC
technical/government/Env_Prot_Agen
technical/government/Alcohol_Problems
...
-maxdepth (Source: redhat.com)
technical directory, with a max depth of 2. This is useful for finding the subdirectories closest to the parent directory, without having to look through a super long list of every single subdirectory.
$ find technical -maxdepth 2 -type d
technical
technical/government
technical/government/About_LSC
technical/government/Env_Prot_Agen
...
911 report directory. This is useful if you want to ignore the contents of any subdirectories and only look for things directly inside the parent directory.
$ find technical/911report -maxdepth 1
technical/911report
technical/911report/chapter-13.4.txt
technical/911report/chapter-13.5.txt