Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {

    public static List<Long> crossing(List<Long> list1, List<Long> list2) {
        List<Long> resultList = new ArrayList();
        for (Long l : list1) {
            if (list2.contains(l)) {
                resultList.add(l);
            }
        }
        return resultList;
    }

    public static Set<Long> crossing(Set<Long> list1, Set<Long> list2) {
        Set<Long> resultList = new HashSet();
        for (Long l : list1) {
            if (list2.contains(l)) {
                resultList.add(l);
            }
        }
        return resultList;
    }
}