Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

get frequency of letters java

HashMap<Character, Integer> map = new HashMap<Character, Integer>();
String s = "aasjjikkk";
for (int i = 0; i < s.length(); i++) {
    char c = s.charAt(i);
    Integer val = map.get(c);
    if (val != null) {
        map.put(c, new Integer(val + 1));
    }
    else {
       map.put(c, 1);
   }
}
Comment

frequency of letters in english java

Map<Character, Long> frequency =
            str.chars()
               .mapToObj(c -> (char)c)
               .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
Comment

PREVIOUS NEXT
Code Example
Java :: ternary operator in java for null check 
Java :: milliseconds to seconds java 
Java :: how to instance a calendar in java 
Java :: rotate a linked list 
Java :: Instant class java 
Java :: java if or 
Java :: android studio alert dialog box 
Java :: for each loop java 
Java :: random boolean java 
Java :: Send image file to server useing Retrofit 
Java :: How to find the logged-in user in Spring Boot? 
Java :: formula to calculate area of a triangle java 
Java :: remove duplicates from sorted array 
Java :: array input java 
Java :: integer.tostring java 
Java :: android double click to exit 
Java :: how to find some of digits in java 
Java :: how to read comma separated values in java 
Java :: how to use sql file in java 
Java :: how to take max value from priority queue in java 
Java :: android studio edittext enter pressed 
Java :: android java Check Wifi Connection 
Java :: java final meaning 
Java :: String remove duplicate method in java 
Java :: sort comparator in java 
Java :: how to use user uid in android 
Java :: arrays.copy 2d array 
Java :: mouselistener in java 
Java :: char to ascii java 
Java :: how to run java files 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =