Assignemnt # compareTo() Challenge
Code
/// Name: Jake Johnson
/// Period: 7
/// Program Name: compareToChallenge
/// File Name: compareToChallenge.java
/// Date Finished: 11/30/2015
public class compareToChallenge
{
public static void main(String[] args)
{
System.out.print("Comparing \"apple\" with \"coffee\" produces ");
System.out.println( "apple".compareTo("coffee") );
System.out.print("Comparing \"applebee's\" with \"apple\" produces ");
System.out.println( "applebee's".compareTo("apple") );
System.out.print("Comparing \"abrogate\" with \"abscess\" produces ");
System.out.println( "abrogate".compareTo("abscess") );
System.out.print("Comparing \"biblio\" with \"bible-thumper\" produces ");
System.out.println( "biblio".compareTo("bible-thumper") );
System.out.print("Comparing \"cat\" with \"cat\" produces ");
System.out.println( "cat".compareTo("cat") );
System.out.print("Comparing \"&%$^\" with \"&%$^\" produces ");
System.out.println( "&%$^".compareTo("&%$^") );
System.out.print("Comparing \"anti\" with \"ant\" produces ");
System.out.println( "anti".compareTo("ant") );
System.out.print("Comparing \"qqqqq\" with \"qqq\" produces ");
System.out.println( "qqqqq".compareTo("qqq") );
System.out.print("Comparing \"zabq\" with \"zabq!\" produces ");
System.out.println( "zabq".compareTo("zabq!") );
System.out.print("Comparing \"AP\" with \"APostrophe\" produces ");
System.out.println( "AP".compareTo("APostrophe") );
System.out.print("Comparing \"A\" with \"a\" produces ");
System.out.println( "A".compareTo("a") );
System.out.print("Comparing \"lazer\" with \"laZer\" produces ");
System.out.println( "lazer".compareTo("laZer") );
}
}
Picture of the output