Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Print Count Strings
import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; class Rextester{ public static void main(String[] args){ List<String> list = new ArrayList<String>(); String in = "Andrey Lena Jacky Chily Lena Chily Lena Lena Jacky"; String[] a = in.split(" "); int count; for (String s : a) { count = 0; for (int i = 0; i<a.length; i++) { Pattern p = Pattern.compile(a[i]); Matcher m = p.matcher(s); while (m.find()) count++; } list.add(count + ": " + s);} Set<String> set = new TreeSet<String>(list); set = ((TreeSet<String>)set).descendingSet(); for (String string : set){System.out.println(string);}} }
run
|
edit
|
history
|
help
0
Problem: on_off
練習3-6
// Java Coding Challenge - 07: Print out Fibonacci number 0 - 1000
kjhkj
rextester.java1
Fireball Plugin
m-primes
exp.1A
Combination Sum (Leetcode)
Alphabets