Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.List;
import java.util.ListIterator;

public class Main {
    public static <T> boolean listEquals(List<T> left, List<T> right) {
        if (left == right)
            return true;

        ListIterator<T> leftIterator = left.listIterator();
        ListIterator<T> rightIterator = right.listIterator();

        while (leftIterator.hasNext() && rightIterator.hasNext()) {
            T leftElement = leftIterator.next();
            T rightElement = rightIterator.next();
            if (!(leftElement == null ? rightElement == null : leftElement.equals(rightElement)))
                return false;
        }
        return !(leftIterator.hasNext() || rightIterator.hasNext());
    }
}