Skip to content

Commit

Permalink
Merge pull request Aniket965#4756 from AlexShepherd28/patch-5
Browse files Browse the repository at this point in the history
Merged by aniket965
  • Loading branch information
Aniket965 authored Oct 18, 2018
2 parents 57e1e07 + fedd5cf commit c0d502f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Java/StringCompareTo.java
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);
}
}
}

0 comments on commit c0d502f

Please sign in to comment.