COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Selections/Decisions MinValue.java PrintingService.java QuadraticEquation.java PayrollWithDecision.java MultiSelection.java CalculatorWithSwitch.java GradeBookWithSwitch.java StringComparison.java



StringComparison Program


Description

This program prompts the user to input two strings and then compare them using == operator, equals method, and compareTo method.

Associated Concepts:

String method:

equals

equalsIgnoreCase

compareTo

compareToIgnoreCase

Algorithm:

Input two string objects from the keyboard

Use == operator to compare them and print a message accordingly

Use equals() or equalsIgnoreCase() method to compare them and print a message accordingly

Use compareTo() or compareToIgnoreCase() method to compare them and print a message accordingly

Source Code



Sample Run



Video