Assignemnt #50 CompareTo() Challange
Code
///Tyler Hart
///period 5
///compareTo() challange
///CompareTo.java
///10/26/2015
public class CompareTo
{
public static void main( String [] args)
{
///int A,B,C,D,E,F,G,H,I,J,K,L;
System.out.print("Comparing \"axe\" with \"dog\" produces ");
int A = "axe".compareTo("dog");
System.out.println(A);
System.out.print("Comparing \"cat\" with \"mouse\" produces ");
int B = "cat".compareTo("mouse");
System.out.println(B);
System.out.print("Comparing \"I\" with \"dont\" produces ");
int C = "I".compareTo("dont");
System.out.println(C);
System.out.print("Comparing \"know\" with \"like\" produces ");
int D = "know".compareTo("like");
System.out.println(D);
System.out.print("Comparing \"apple\" with \"potato\" produces ");
int E = "apple".compareTo("potato");
System.out.println(E);
System.out.print("Comparing \"With\" with \"With\" produces ");
int F = "With".compareTo("With");
System.out.println(F);
System.out.print("Comparing \"Compare\" with \"Compare\" produces ");
int G = "Compare".compareTo("Compare");
System.out.println(G);
System.out.print("Comparing \"squirrel\" with \"carrot\" produces ");
int H = "squirrel".compareTo("carrot");
System.out.println(H);
System.out.print("Comparing \"paper clip\" with \"moose\" produces ");
int I = "paper clip".compareTo("moose");
System.out.println(I);
System.out.print("Comparing \"watermelon\" with \"Camaro\" produces ");
int J = "watermelon".compareTo("Camaro");
System.out.println(J);
System.out.print("Comparing \"space\" with \" \" produces ");
int k = "space".compareTo(" ");
System.out.println(k);
System.out.print("Comparing \"Html\" with \"CSS\" produces ");
int L = "Html".compareTo("CSS");
System.out.println(L);
}
}
Picture of the output