I have to write a program that accepts two command line string arguments and prints the lesser of them, if case is ignored. The program should look like this when it runs:
$
java Main Zoophyte aardvark
aardvark
$
This is the code I have so far:
public class LeastString {
public static void main (String[] args) {
String s = args[0];
String t = args[1];
System.out.println(s.trim());
System.out.println(t.trim());
System.out.println(s.compareToIgnoreCase(t));
if (s > t) {
System.out.println(s);
} else (s < t){
System.out.println(t);
}
}
}
if (s.compareToIgnoreCase(t) < 0) { System.out.println(s);//print s if it lesser than t } else if (s.compareToIgnoreCase(t) > 0) { System.out.println(t); }
Comments
Leave a comment