Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 19, Problem 14SA
Program Plan Intro

“hashCode” method:

  • The hash code is an integer value which is the characteristic of an object.
  • The hashing algorithm is used to evaluate a hash code for an object.
  • Different objects in the code contain same data and a hashing algorithm should give the same hash code for both.
  • For example, if the user wants to evaluate the hash code for a string, he would use the characters making up the string in the calculation. Possibly the user would use each character’s Unicode value in a mathematical formula which would give us an integer value.

“equals” method:

  • The “equals” method finds whether the number object which invokes the method is equal to the object which is passed as an argument.
  • This method will return “false” if the argument is null and the argument is an object of the different type with the different numeric value.

Blurred answer
Students have asked these similar questions
Computer Science : Using Java implement the following lab experiment using HashMap. Create a class Product with following details Instance Variable: pid(int), product_name(String), price (double) Overloaded Constructor toString() method Create another class called TestProductMap and implement the following in the main method: Create 10 products Create HashMap that accepts key integer and value product. Ex: HashMap<int, Product> Add all the product to the HashMap, every product key is 1, 2, 3 … so on Display the HashMap Add duplicate product to the map with different key Get the duplicate product that you just added to the list and display it. Delete a product from the HashMap. Display the HashMap
Java Code: Look through the Language Description and build a list of keywords. Add a HashMap to your Lexer class and initialize all the keywords. Change your lexer so that it checks each string before making the WORD token and creates a token of the appropriate type if the work is a key word. When the exact type of a token is known (like “WHILE”), you should NOT fill in the value string, the type is enough. For tokens with no exact type (like “hello”), we still need to fill in the token’s string. Finally, rename “WORD” to “IDENTIFIER”. Similarly, look through the Language Description for the list of punctuation. A hash map is not necessary or helpful for these – they need to be added to your state machine. Be particularly careful about the multi-character operators like := or >=. These require a little more complexity in your state machine.  Strings and characters will require some additions to your state machine. Create “STRINGLITERAL” and “CHARACTERLITERAL” token types. These…
Hashing  Create a method hashSetExe to use Java HashSet to store elements and print them. For example, input the elements: “Apple”, “Mango”, and “Grapes”. Please state what the output would be when printing the HashSet with the three elements.  Create a method treeSetExe to use Java TreeSet to store elements and print them. For example, input the elements: “Apple”, “Mango”, and “Grapes”. Please state what the output would be when printing the TreeSet with the three elements.  Create a hashing function that takes the string, calculate the sum of the ASCII code of each character, and return (sum%tableSize) as the index. For example, hash(“ab”, 11) returns 8, because ‘a’ is 97 and ‘b’ is 98, which adds up to 195, and 195%11 returns 8.

Chapter 19 Solutions

Starting Out with Java: From Control Structures through Data Structures (3rd Edition)

Ch. 19.2 - Prob. 19.11CPCh. 19.2 - Prob. 19.12CPCh. 19.2 - Prob. 19.13CPCh. 19.2 - Prob. 19.14CPCh. 19.2 - Prob. 19.16CPCh. 19.2 - Prob. 19.17CPCh. 19.2 - Prob. 19.18CPCh. 19.2 - Prob. 19.20CPCh. 19.3 - Prob. 19.21CPCh. 19.3 - Prob. 19.22CPCh. 19.3 - Prob. 19.23CPCh. 19.3 - Prob. 19.24CPCh. 19.3 - Any time you override the Object classs equals...Ch. 19.3 - Prob. 19.26CPCh. 19.3 - Prob. 19.27CPCh. 19.3 - Prob. 19.28CPCh. 19.4 - Prob. 19.29CPCh. 19.4 - Prob. 19.31CPCh. 19.4 - Prob. 19.32CPCh. 19.6 - How do you define a stream of elements?Ch. 19.6 - How does a stream intermediate operation differ...Ch. 19.6 - Prob. 19.35CPCh. 19.6 - Prob. 19.36CPCh. 19.6 - Prob. 19.37CPCh. 19.6 - Prob. 19.38CPCh. 19.6 - Prob. 19.39CPCh. 19 - Prob. 1MCCh. 19 - Prob. 2MCCh. 19 - This type of collection is optimized for...Ch. 19 - Prob. 4MCCh. 19 - A terminal operation in a stream pipeline is also...Ch. 19 - Prob. 6MCCh. 19 - Prob. 7MCCh. 19 - This List Iterator method replaces an existing...Ch. 19 - Prob. 9MCCh. 19 - Prob. 10MCCh. 19 - This is an object that can compare two other...Ch. 19 - This class provides numerous static methods that...Ch. 19 - Prob. 13MCCh. 19 - Prob. 14MCCh. 19 - Prob. 15TFCh. 19 - Prob. 16TFCh. 19 - Prob. 17TFCh. 19 - Prob. 18TFCh. 19 - Prob. 19TFCh. 19 - Prob. 20TFCh. 19 - Prob. 21TFCh. 19 - Prob. 22TFCh. 19 - Prob. 1FTECh. 19 - Prob. 2FTECh. 19 - Prob. 3FTECh. 19 - Prob. 4FTECh. 19 - Write a statement that declares a List reference...Ch. 19 - Prob. 2AWCh. 19 - Assume that it references a newly created iterator...Ch. 19 - Prob. 4AWCh. 19 - Prob. 2SACh. 19 - Prob. 4SACh. 19 - Prob. 5SACh. 19 - Prob. 6SACh. 19 - How does the Java compiler process an enhanced for...Ch. 19 - Prob. 8SACh. 19 - Prob. 9SACh. 19 - Prob. 10SACh. 19 - Prob. 11SACh. 19 - Prob. 12SACh. 19 - Prob. 13SACh. 19 - Prob. 14SACh. 19 - Word Set Write an application that reads a line of...Ch. 19 - Prob. 3PCCh. 19 - Prob. 5PCCh. 19 - Prob. 8PC
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education