Assignment 50
Code
/// Name: Josh Bautista
/// Period: 6
/// Program Name: CompareTo
/// File Name: CompareTo.java
/// Date Finished: 12/10/2015
public class CompareTo
{
public static void main( String []args )
{
System.out.print("Comparing \"far\"with \"par\" produces ");
int i = "far".compareTo("par");
System.out.println(i);
System.out.print("Comparing \"car\"with \"zhar\" produces ");
int g = "car".compareTo("zhar");
System.out.println(g);
System.out.print("Comparing \"Butt\"with \"Rutt\" produces ");
int b = "Butt".compareTo("Rutt");
System.out.println(b);
System.out.print("Comparing \"KingKong\" with \"Banana\" produces");
System.out.println( "KingKong".compareTo("Banana") );
System.out.print("Comparing \"CEO\" with \"BEO\" produces");
System.out.println( "CEO".compareTo("BEO") );
System.out.print("Comparing \"PingPong\" with \"Ball\" produces");
System.out.println( "PingPong".compareTo("Ball") );
System.out.print("Comparing \"Phaser\" with \"Laser\" produces");
System.out.println( "Phaser".compareTo("Laser") );
System.out.print("Comparing \"Orange\" with \"Orange\" produces");
System.out.println( "Orange".compareTo("Orange") );
System.out.print("Comparing \"Warriors\" with \"Warriors\" produces");
System.out.println( "Warriors".compareTo("Warriors") );
}
}
Picture of Output