Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
25 lines (21 loc) · 1.06 KB

File metadata and controls

25 lines (21 loc) · 1.06 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package org.launchcode;
import java.util.HashMap;
import java.util.Map;
public class CharacterCount {
public static void main(String[] args) {
String hiddenFig = "If the product of two terms is zero then common sense says at least one of the two terms has to be zero to start with. So if you move all the terms over to one side, you can put the quadratics into a form that can be factored allowing that side of the equation to equal zero. Once you’ve done that, it’s pretty straightforward from there.";
char[] charHiddenFig = hiddenFig.toCharArray();
HashMap<Character, Integer> counts = new HashMap<>();
for (char letter : charHiddenFig) {
if (counts.containsKey(letter)) {
counts.put(letter, counts.get(letter) + 1);
} else {
counts.put(letter, 1);
}
}
for (Map.Entry<Character, Integer> count : counts.entrySet()) {
System.out.println(count.getKey() + ": " + count.getValue());
}
input.close();
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.