CSE 116 Study Guide - Local Variable

50 views3 pages

Document Summary

Reflections on hw3 the practice problem. In hw1 you wrote code to count characters in a given string. The overall count of a character (or group of characters) was returned as single int value. The overall counts of characters were returned in an array of ints. In hw3 you wrote code to count the number of times words occurred in a file. The overall counts of characters were returned in a hashmap. Here"s one possible solution to the hw3 practice problem: Map" is a local variable; it will be used to hold word- count mappings. An iterator- controlled while loop whose body is done as long as there are more chars to process. The count of the word just found is added to (or updated in the map). It uses some private helper methods. Characterfromfilereader cffr = new characterfromfilereader(path); while (cffr. hasnext()) { addtomap(map, word); return map; C" is the next character from the file.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents

Related Questions