Assignemnt #50 and compareTo Challenge
Code
/// Name: Raff Lisbona
/// Period: 6
/// Program Name: compareTo Challenge
/// File Name: compareToChallenge.java
/// Date Finished: 11/3/2015
public class compareToChallenge
{
public static void main( String[] args )
{
System.out.print("Comparing \"sam\" with \"david\" produces ");
int i = "sam".compareTo("david");
System.out.println(i);
System.out.print("Comparing \"kabir\" with \"connor\" produces ");
System.out.println( "kabir".compareTo("connor"));
System.out.print("Comparing \"hand\" with \"finger\" produces ");
System.out.println("hand".compareTo("finger"));
System.out.print("Comparing \"head\" with \"hair\" produces ");
System.out.println("head".compareTo("hair"));
System.out.print("Comparing \"watermelon\" with \"black\" produces ");
System.out.println("watermelon".compareTo("black"));
System.out.print("Comparing \"keyboard\" with \"mouse\" produces ");
System.out.println("keyboard".compareTo("mouse"));
System.out.print("Comparing \"aphabet\" with \"soup\" produces ");
System.out.println("alphabet".compareTo("soup"));
System.out.print("Comparing \"board\" with \"marker\" produces ");
System.out.println("board".compareTo("marker"));
System.out.print("Comparing \"help\" with \"me\" produces ");
System.out.println("help".compareTo("me"));
System.out.print("Comparing \"chair\" with \"ground\" produces ");
System.out.println("chair".compareTo("ground"));
System.out.print("Comparing \"large\" with \"large\" produces ");
System.out.println("large".compareTo("large"));
System.out.print("Comparing \"sam\" with \"sam\" produces ");
System.out.println("sam".compareTo("sam"));
}
}
Picture of the output