Last active
April 15, 2019 16:51
-
-
Save tcelik/3b97b297b14126ecca8d5117043bd5d3 to your computer and use it in GitHub Desktop.
Mülakat sorusu olarak soruldu. Geleneksel Yöntem, Collection Yöntem, Lambda Yöntemi.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StringUtil { | |
// "baba" a:2, b:2 tane var gibi mesela. | |
public static HashMap<Character, Integer> countOccurencesWithHashMapWay(String str) | |
{ | |
char [] strArray = str.toCharArray(); | |
HashMap<Character, Integer> hm = new HashMap<>(); | |
for (char ch : strArray) | |
if (hm.containsKey(ch)) | |
hm.put(ch, hm.get(ch) + 1); | |
else | |
hm.put(ch, 1); | |
return hm; | |
} | |
} |
Author
tcelik
commented
Apr 15, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment