Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import java.util.Set;

public class Main {
    public static long contains(List list) {
        long start, stop, result = 0;
        for (int i = 0; i < 100; i++) {
            start = System.nanoTime();
            list.contains(list.size() - i);
            stop = System.nanoTime();
            result += stop - start;
        }
        return result / 100;
    }

    public static long contains(Set set) {
        long start, stop, result = 0;
        for (int i = 0; i < 100; i++) {
            start = System.nanoTime();
            set.contains(set.size() - i);
            stop = System.nanoTime();
            result += stop - start;
        }
        return result / 100;
    }
}