Here you can find the source of countCommonTokens(String string1, String string2)
public static int countCommonTokens(String string1, String string2)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static int countCommonTokens(String string1, String string2) { List<String> string1Tokens = new ArrayList<String>(Arrays.asList(string1.split("\\s+"))); List<String> string2Tokens = new ArrayList<String>(Arrays.asList(string2.split("\\s+"))); string1Tokens.retainAll(string2Tokens); return string1Tokens.size(); }/* w w w .j a v a2s.c o m*/ }