Created
April 16, 2019 10:43
-
-
Save tcelik/a4324441e35a0c92ead456863d5fe4e6 to your computer and use it in GitHub Desktop.
Lambda İle String Operation - Java8 ile derle, çalıştır. Paketi yok doğrudan javac App.java, java App
This file contains hidden or 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
public class App { | |
public static void main(String[] args) | |
{ | |
Utils.run(new java.util.HashMap<Character, Integer>()); | |
} | |
} | |
class Utils { | |
public static java.util.HashMap<Character, Integer> run(java.util.HashMap<Character, Integer> hm) | |
{ | |
"Araba".chars().mapToObj(val -> (char)val).forEach(ch -> { | |
if (hm.containsKey(ch)) | |
hm.put(ch, hm.get(ch) + 1); | |
else | |
hm.put(ch, 1); | |
}); | |
System.out.println(hm); | |
return hm; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment