search For Common String between two set - Java Collection Framework

Java examples for Collection Framework:Set

Description

search For Common String between two set

Demo Code


//package com.java2s;

import java.util.Set;

public class Main {
    public static String searchForCommonString(Set<String> s1,
            Set<String> s2) {
        String matched = "";
        for (String s1Word : s1)
            if (s2.contains(s1Word)) {
                matched = s1Word;//from ww w .ja va  2  s. c om
                break;
            }
        return matched;
    }
}

Related Tutorials