forked from Aniket965/Hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Aniket965#4756 from AlexShepherd28/patch-5
Merged by aniket965
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
This program compares two String objects using | ||
the compareTo method. | ||
*/ | ||
|
||
public class StringCompareTo | ||
{ | ||
public static void main(String [] args) | ||
{ | ||
String name1 = "MARK", | ||
name2 = "Mark"; | ||
|
||
// Compare "Mary" and "Mark" | ||
|
||
if (name1.compareTo(name2) < 0) | ||
{ | ||
System.out.println(name1 + " is less than " + name2); | ||
} | ||
else if (name1.compareTo(name2) == 0) | ||
{ | ||
System.out.println(name1 + " is equal to " + name2); | ||
} | ||
else if (name1.compareTo(name2) > 0) | ||
{ | ||
System.out.println(name1 + " is greater than " + name2); | ||
} | ||
} | ||
} |