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.Comparator;
import java.util.List;

public class Main {
    public static void main(String args[]) {
        String str[] = { "B", "H", "L", "M", "R" };
        List list = Arrays.asList(str);
        System.out.println(Collections.min(list));
        System.out.println(Collections.max(list));
        Comparator comp = Collections.reverseOrder();
        System.out.println(Collections.min(list, comp));
        System.out.println(Collections.max(list, comp));
    }
}