We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents adfb805 + 1307b16 commit c2e01eeCopy full SHA for c2e01ee
1 file changed
wordshash.java
@@ -0,0 +1,22 @@
1
+import java.util.HashMap;
2
+
3
+public class FinalCountWords {
4
5
+ public static void main(String[] args) {
6
+ String str = "This this is is done by Saket Saket";
7
+ String[] split = str.split(" ");
8
9
+ HashMap<String,Integer> map = new HashMap<String,Integer>();
10
+ for (int i=0; i<split.length; i++) {
11
+ if (map.containsKey(split[i])) {
12
+ int count = map.get(split[i]);
13
+ map.put(split[i], count+1);
14
+ }
15
+ else {
16
+ map.put(split[i], 1);
17
18
19
+ System.out.println(map);
20
21
22
+}
0 commit comments