Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    /**
     *
     * @param lstSrc List
     * @param lstDes List
     * @return boolean
     */
    ////////////////////////////////////////////////////////
    public static boolean isSimilar(List lstSrc, List lstDes) {
        if (lstSrc != lstDes) {
            if (lstSrc.size() != lstDes.size())
                return false;
            for (int iIndex = 0; iIndex < lstSrc.size(); iIndex++) {
                Object objSrc = lstSrc.get(iIndex);
                Object objDes = lstDes.get(iIndex);
                if (objSrc == null && objDes == null)
                    continue;
                if (objSrc == null)
                    return false;
                if (objDes == null)
                    return false;
                if (objSrc.getClass() != objDes.getClass())
                    return false;
                if (objSrc instanceof List && !isSimilar((List) objSrc, (List) objDes))
                    return false;
                if (!objSrc.equals(objDes))
                    return false;
            }
        }
        return true;
    }
}