diff --git a/data/part-7/3-larger-exercises.md b/data/part-7/3-larger-exercises.md index 36560fe4e..41d989866 100644 --- a/data/part-7/3-larger-exercises.md +++ b/data/part-7/3-larger-exercises.md @@ -737,7 +737,7 @@ Crow (Corvus Corvus): 0 observations ? **One** Bird? **Hawk** Hawk (Dorkus Dorkus): 2 observations -? **Lopeta** +? **Quit** diff --git a/data/part-8/2-hash-map.md b/data/part-8/2-hash-map.md index af60cd9ff..019e6aa5c 100644 --- a/data/part-8/2-hash-map.md +++ b/data/part-8/2-hash-map.md @@ -1016,7 +1016,7 @@ This way, however, we lose the speed advantage that comes with the hash map. The -Exercise template contains a class `Program`. Implement the following class methods in the clas: +Exercise template contains a class `Program`. Implement the following class methods in the class: @@ -1117,7 +1117,7 @@ In the class `Program` implement the following class methods: the toString method of the Book objects. -`public static void printValueIfNameContains(HashMap hashmap, String text)`, which prints only the Books in the given hashmap whichs name contains the given string. You can find out the name of a Book with the method `getName`. +- `public static void printValueIfNameContains(HashMap hashmap, String text)`, which prints only the Books in the given hashmap which name contains the given string. You can find out the name of a Book with the method `getName`. An example of using the class methods: @@ -1162,7 +1162,7 @@ NB! The order of the output may vary. The implementation of a hashmap does not g -A hash map expects that only reference-variables are added to it (in the same way that `ArrayList` does). Java converts primitive variables to their corresponding reference-types when using any Java's built in data structures (such as ArrayLisr and HashMap). Although the value `1` can be represented as a value of the primitive `int` variable, its type should be defined as `Integer` when using ArrayLists and HashMaps. +A hash map expects that only reference-variables are added to it (in the same way that `ArrayList` does). Java converts primitive variables to their corresponding reference-types when using any Java's built in data structures (such as ArrayList and HashMap). Although the value `1` can be represented as a value of the primitive `int` variable, its type should be defined as `Integer` when using ArrayLists and HashMaps. -We find the borrower when searching for the same object that was given as a key to the hash map's `put` method. However, when searching by the exact same book but with a different object,a borrwer isn't found, and we get the _null_ reference instead. The reason lies in the default implementation of the `hashCode` method in the `Object` class. The default implementation creates a `hashCode` value based on the object's reference, which means that books having the same content that are nonetheless different objects get different results from the hashCode method. As such, the object is not being searched for in the right place. +We find the borrower when searching for the same object that was given as a key to the hash map's `put` method. However, when searching by the exact same book but with a different object, a borrower isn't found, and we get the _null_ reference instead. The reason lies in the default implementation of the `hashCode` method in the `Object` class. The default implementation creates a `hashCode` value based on the object's reference, which means that books having the same content that are nonetheless different objects get different results from the hashCode method. As such, the object is not being searched for in the right place. For the HashMap to work in the way we want it to, that is, to return the borrower when given an object with the correct _content_ (not necessarily the same object as the original key), the class that the key belongs to must overwrite the `hashCode` method in addition to the `equals` method. The method must be overwritten so that it gives the same numerical result for all objects with the same content. Also, some objects with different contents may get the same result from the hashCode method. However, with the HashMap's performance in mind, it is essential that objects with different contents get the same hash value as rarely as possible. diff --git a/data/part-9/1-inheritance.md b/data/part-9/1-inheritance.md index f469a6cac..5759d487e 100644 --- a/data/part-9/1-inheritance.md +++ b/data/part-9/1-inheritance.md @@ -556,7 +556,7 @@ System.out.println("opintopisteitä "+ olli.opintopisteita()); Student ollie = new Student("Ollie", "6381 Hollywood Blvd. Los Angeles 90028"); System.out.println(ollie); System.out.println("Study credits " + ollie.credits()); -olli.study(); +ollie.study(); System.out.println("Study credits "+ ollie.credits()); ``` @@ -595,7 +595,7 @@ System.out.println(olli); ```java Student ollie = new Student("Ollie", "6381 Hollywood Blvd. Los Angeles 90028"); System.out.println(ollie); -olli.study(); +ollie.study(); System.out.println(ollie); ```