判断两个ArrayList元素是否相同

引入guava包

		<dependency>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
			<version>25.1-jre</version>
		</dependency>	    

  

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertTrue;

/**
 * Description:
 *
 * @author maduar maduar@163.com
 * @version 1.1.1 30/04/2019
 */
public class UsrDueJobsEnumTest {
    
    @Test
    public void arrayTest(){
        List<String> list = Lists.newArrayList(
                "0",
                "3",
                "7",
                "15",
                "30",
                "60",
                "90"
        );

        List<String> dayList = new ArrayList<String>();
        dayList.add("0");
        dayList.add("3");
        dayList.add("7");
        dayList.add("15");
        dayList.add("30");
        dayList.add("60");
        dayList.add("90");

        System.out.println(Arrays.toString(list.toArray()));
        System.out.println(Arrays.toString(dayList.toArray()));

        boolean b = Iterators.elementsEqual(list.iterator(), dayList.iterator());

        assertTrue(b);

    }
}

  

posted @ 2019-04-30 14:53  金色元年  阅读(3770)  评论(0编辑  收藏  举报