If statement part 2 #50 (I still don't understand this.)

Code

/// Name: Amir Salehi
/// Period: 7
/// Program Name: Compare to Challenge
/// File Name: CompareToChallenge.java
/// Date Finished: 11/5/2015


public class CompareToChallenge {

    public static void main(String[] args) {

        String[] strings = new String[] {
                "apple", "bear",
                "keyboard", "mouse",
                "theater", "theatre",
                "computer", "monitor",
                "book", "teacup",
                "transport", "translate",
                "motherboard", "keyboard",
                "centre", "center",
                "kangaroo", "coffee",
                "duly", "dull",
                "apple", "apple",
                "jump", "jump"
        };
        for (int i = 0; i < strings.length; i += 2) {
            System.out.println("Comparing \"" + strings[i] + "\" with \"" + strings[i + 1] + "\" produces " + strings[i].compareTo(strings[i + 1]) + ".");
        }

    }

}
    

Picture of the output

Assignment 7

Back to Homepage