Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2006-2010 eBay Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *******************************************************************************/

import java.util.HashSet;
import java.util.Set;

public class Main {
    /**
     * Intersection.
     *
     * @param <T> the generic type
     * @param set1 the set1
     * @param set2 the set2
     * @return Uses the intersection paradigm. Non destructive
     */
    public static <T> Set<T> intersection(Set<T> set1, Set<T> set2) {
        Set<T> tempSet = new HashSet<T>(set1);
        tempSet.retainAll(set2);
        return tempSet;
    }
}