Reporting the lexicographically minimum string of the command line arguments - Java Language Basics

Java examples for Language Basics:int

Description

Reporting the lexicographically minimum string of the command line arguments

Demo Code

public class Main {
  public static void main(String[] args) {
    String minimum = args[0];// w ww. java 2 s  .com

    for (int i = 1; i < args.length; i++)
      if (minimum.compareTo(args[i]) > 0)
        minimum = args[i];

    System.out.println("Lexicographically minimum string is:" + minimum);
  }
}

Related Tutorials