Skip to content

Instantly share code, notes, and snippets.

@tcelik
Created April 16, 2019 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcelik/a4324441e35a0c92ead456863d5fe4e6 to your computer and use it in GitHub Desktop.
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
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