Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class Main {
    public static void main(String[] argv) {

        List<String> sortedList = new LinkedList<String>();
        sortedList.addAll(Arrays.asList(new String[] { "a", "b", "c", "d" }));

        int index = Collections.binarySearch(sortedList, "c");
        System.out.println(index);

        index = Collections.binarySearch(sortedList, "e");
        System.out.println(index);
    }
}
/*
2
-5
*/