Assignemnt #50 and compareTo Challenge
Code
/// Name: David Shkolnikov
/// Period: 6
/// Program Name: compareTo Challenge
/// File Name: compareToChallenge.java
/// Date Finished: 11/16/2015
public class compareToChallenge
{
public static void main( String[] args )
{
System.out.print("Comparing \"Trevor\" with \"Mohsen\" produces ");
int i = "Trevor".compareTo("Mohsen");
System.out.println(i);
System.out.print("Comparing \"twelve\" with \"four\" produces ");
System.out.println( "twelve".compareTo("four"));
System.out.print("Comparing \"Trash\" with \"Raff\" produces ");
System.out.println("Trash".compareTo("Raff"));
System.out.print("Comparing \"Danny\" with \"Conner\" produces ");
System.out.println("Danny".compareTo("Conner"));
System.out.print("Comparing \"policeman\" with \"fireman\" produces ");
System.out.println("policeman".compareTo("fireman"));
System.out.print("Comparing \"piglet\" with \"rabbit\" produces ");
System.out.println("piglet".compareTo("rabbit"));
System.out.print("Comparing \"David\" with \"Sam\" produces ");
System.out.println("David".compareTo("Sam"));
System.out.print("Comparing \"harmony\" with \"sing\" produces ");
System.out.println("harmony".compareTo("sing"));
System.out.print("Comparing \"hug\" with \"smile\" produces ");
System.out.println("hug".compareTo("smile"));
System.out.print("Comparing \"elephant\" with \"flamingo\" produces ");
System.out.println("elephant".compareTo("flamingo"));
System.out.print("Comparing \"leg\" with \"leg\" produces ");
System.out.println("leg".compareTo("leg"));
System.out.print("Comparing \"jumping\" with \"jumping\" produces ");
System.out.println("jumping".compareTo("jumping"));
}
Picture of the output