Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
35
Task/String-comparison/Apex/string-comparison.apex
Normal file
35
Task/String-comparison/Apex/string-comparison.apex
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
public class Compare
|
||||
{
|
||||
/**
|
||||
* Test in the developer console:
|
||||
* Compare.compare('Hello', 'Hello');
|
||||
* Compare.compare('5', '5.0');
|
||||
* Compare.compare('java', 'Java');
|
||||
* Compare.compare('ĴÃVÁ', 'ĴÃVÁ');
|
||||
*/
|
||||
|
||||
public static void compare (String A, String B)
|
||||
{
|
||||
if (A.equals(B))
|
||||
System.debug(A + ' and ' + B + ' are lexically equal.');
|
||||
else
|
||||
System.debug(A + ' and ' + B + ' are not lexically equal.');
|
||||
|
||||
if (A.equalsIgnoreCase(B))
|
||||
System.debug(A + ' and ' + B + ' are case-insensitive lexically equal.');
|
||||
else
|
||||
System.debug(A + ' and ' + B + ' are not case-insensitive lexically equal.');
|
||||
|
||||
if (A.compareTo(B) < 0)
|
||||
System.debug(A + ' is lexically before ' + B);
|
||||
else if (A.compareTo(B) > 0)
|
||||
System.debug(A + ' is lexically after ' + B);
|
||||
|
||||
if (A.compareTo(B) >= 0)
|
||||
System.debug(A + ' is not lexically before ' + B);
|
||||
if (A.compareTo(B) <= 0)
|
||||
System.debug(A + ' is not lexically after ' + B);
|
||||
|
||||
System.debug('The lexical relationship is: ' + A.compareTo(B));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue