Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

frequency of each element from list in java

    public static void main(String[] args)
    {
        List<String> list = Arrays.asList("B", "A", "A", "C", "B", "A");

        Set<String> distinct = new HashSet<>(list);
        for (String s: distinct) {
            System.out.println(s + ": " + Collections.frequency(list, s));
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: lambda comparator java 
Java :: java regex 10 digit number 
Java :: how to get input form combobox java 
Java :: how to resize image in java swing 
Java :: getcurrencyinstance java example 
Java :: json to hashmap java stream 
Java :: android recyclerview item click listener 
Java :: print list array 
Java :: java loop over string 
Java :: java print 
Java :: fibonacci number in java 
Java :: java find all of letter in string 
Java :: java catch multiple exceptions 
Java :: java button size 
Java :: java comments 
Java :: how to print something in java 
Java :: how to instance a calendar in java 
Java :: sort an int array java 
Java :: Spring boot enable openapi swagger accessed 
Java :: fill two dimensional array row by row java 
Java :: gridlayout android studio 
Java :: binary to decimal conversion in java 
Java :: java hash password 
Java :: java how to compare strings 
Java :: java array add element 
Java :: setbackground java 
Java :: mockito mock void methods 
Java :: print array 
Java :: boucle for avec un tableau java 
Java :: java print item to text file 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =