EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 8PE
icon
Related questions
Question

package ch08.apps;
import ch08.maps.*;

public class HMapDriver 
{
  public static void main(String[] args)
  {
    boolean result;
    HMap<String, String> test;
    test = new HMap<String, String>(10,0.75);

/*
String s = null;
test.put(s,"value");
test.put("s",null);
System.out.println("Expect 'null':\t" + test.get("s"));
System.out.println("Expect 'true':\t" + test.contains("s"));
test = new ArrayListMap<String, String>();
*/

 

    System.out.println("Expect 'true':\t" + test.isEmpty());   
    System.out.println("Expect '0':\t" + test.size());  

    System.out.println("Expect 'null':\t" + test.put("1", "One"));
    System.out.println("Expect 'false':\t" + test.isEmpty());   
    System.out.println("Expect '1':\t" + test.size());  

    System.out.println("Expect 'One':\t" + test.put("1", "One"));
    System.out.println("Expect 'false':\t" + test.isEmpty());   
    System.out.println("Expect '1':\t" + test.size());  


    test.put("2", "Two");    
    test.put("3", "Three");    
    test.put("4", "Four");    
    test.put("5", "Five");    
    System.out.println("Expect '5':\t" + test.size());  

    System.out.println("Expect 'Three':\t" + test.put("3", "Three XXX"));
    System.out.println("Expect 'Three XXX':\t" + test.put("3", "Three"));
    System.out.println("Expect '5':\t" + test.size());  

    System.out.println("Expect 'true':\t" + test.contains("5"));
    System.out.println("Expect 'false':\t" + test.contains("6"));

    System.out.println(test);
   
    test.put("d","d");
     
    System.out.println(test);
    System.out.println("Expect 'true':\t" + test.contains("d"));
    System.out.println("Expect 'false':\t" + test.contains("e"));

 

    System.out.println("Expect 'One':\t" + test.get("1"));
    System.out.println("Expect 'One':\t" + test.get("1"));
    System.out.println("Expect 'Two':\t" + test.get("2"));
    System.out.println("Expect 'Three':\t" + test.get("3"));
    System.out.println("Expect 'Four':\t" + test.get("4"));
    System.out.println("Expect 'Five':\t" + test.get("5"));
    System.out.println("Expect 'null':\t" + test.get("6"));

    test.put("e","e");

    System.out.println(test);

    System.out.println("\nThe Map is:\n");
    for (MapEntry<String,String> m: test)
      System.out.println(m + "\n");

System.out.println(1);
    test.put("f","f");
System.out.println(2);
    System.out.println(test);
System.out.println(3);
    System.out.println("\nThe Map is:\n");
    for (MapEntry<String,String> m: test)
      System.out.println(m + "\n");
System.out.println(4);

 

  }
}

3. Create an application that uses HMap from chapter 8 sample codes (bookFiles
folder) and reads a list of words from a provided file and outputs whether or not
any word repeats. As soon as the application determines there is at least one
repeated word it can display "<such and such word> repeats" and terminate. If no
words repeat it displays "No words repeat" and terminates.
Transcribed Image Text:3. Create an application that uses HMap from chapter 8 sample codes (bookFiles folder) and reads a list of words from a provided file and outputs whether or not any word repeats. As soon as the application determines there is at least one repeated word it can display "<such and such word> repeats" and terminate. If no words repeat it displays "No words repeat" and terminates.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Database Environment
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning