Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {

    public static void main(String args[]) {
        List<Character> ll = new LinkedList<Character>();

        for (char n = 'A'; n <= 'Z'; n++)
            ll.add(n);

        Collections.shuffle(ll);

        for (Character x : ll)
            System.out.print(x + " ");
        Collections.sort(ll);

        for (Character x : ll)
            System.out.print(x + " ");

        System.out.println("Searching for F.");
        int i = Collections.binarySearch(ll, 'F');

        if (i >= 0) {
            System.out.println("Found at index " + i);
            System.out.println("Object is " + ll.get(i));
        }
    }
}