Assignemnt #50: Compareto() Challenge
Code
///Name: Cassie
///Period: 6
///Program Name: compareTo() Challenge
///File Name: CompareTo
///Date Finished: 11/6/2015
class Compareto {
public static void main( String[] args ) {
System.out.print("Comparing \"christmas\" with \"tree\" produces ");
int i = "christmas".compareTo("tree");
System.out.println(i);
System.out.print("Comparing \"apple\" with \"sauce\" produces ");
i = "apple".compareTo("sauce");
System.out.println(i);
System.out.print("Comparing \"mother\" with \"father\" produces ");
i = "mother".compareTo("father");
System.out.println(i);
System.out.print("Comparing \"brother\" with \"sister\" produces ");
i = "brother".compareTo("sister");
System.out.println(i);
System.out.print("Comparing \"corn\" with \"flakes\" produces ");
i = "corn".compareTo("flakes");
System.out.println(i);
System.out.print("Comparing \"puppies\" with \"kitties\" produces ");
i = "puppies".compareTo("kitties");
System.out.println(i);
System.out.print("Comparing \"dono\" with \"rich\" produces ");
i = "dono".compareTo("rich");
System.out.println(i);
System.out.print("Comparing \"dark\" with \"light\" produces ");
i = "dark".compareTo("light");
System.out.println(i);
System.out.print("Comparing \"red\" with \"green\" produces ");
i = "rampant".compareTo("growth");
System.out.println(i);
System.out.print("Comparing \"darth\" with \"vader\" produces ");
i = "me".compareTo("gusta");
System.out.println(i);
System.out.print("Comparing \"outer\" with \"space\" produces ");
i = "ha".compareTo("ha");
System.out.println(i);
System.out.print("Comparing \"seth\" with \"rogan\" produces ");
i = "seth".compareTo("rogan");
System.out.println(i);
}
}
Picture of the output