From ggc
|
01 packagepackage is used to name the directory or folder a class is in intermediate;
02 //start auto-imports
03 importimport means to make the classes and/or packages available in this program java.util.*;
04 //end auto-imports
05
06
07 /**
08 * All about my helper classclass is a group of fields and methods used for making objects.
09 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
10 */
11 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects LengthComparator extendsextends means to customize or extend the functionality of a class Object
12 implementsimplements means providing method bodies for the methods declared in the corresponding interface Comparator<String>
13 {open braces start code blocks and must be matched with a close brace
14 publicpublic is used to indicate unrestricted access (any other class can have access) intint is the type for whole numbers and it is short for integer compare(String a, String b)
15 {open braces start code blocks and must be matched with a close brace
16 ifif executes the next statement only if the condition in parenthesis evaluates to true(a==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) b==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object)
17 returnreturn means to provide the result of the method and/or cease execution of the method immediately 0;
18 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(a==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object)
19 returnreturn means to provide the result of the method and/or cease execution of the method immediately -1;
20 elseelse is what happens when the if condition is false ifif executes the next statement only if the condition in parenthesis evaluates to true(b==this is the comparison operator which evaluates to true if both sides are the samenullnull is the value used to refer to a non-existant object)
21 returnreturn means to provide the result of the method and/or cease execution of the method immediately 1;
22 returnreturn means to provide the result of the method and/or cease execution of the method immediately a.length()-b.length();
23 }close braces end code blocks and must match an earlier open brace
24
25 publicpublic is used to indicate unrestricted access (any other class can have access) String toString()
26 {open braces start code blocks and must be matched with a close brace
27 returnreturn means to provide the result of the method and/or cease execution of the method immediately "I am a happy length comparator: "+adds two numbers together or concatenates Strings togethersuper.toString();
28 }close braces end code blocks and must match an earlier open brace
29 }close braces end code blocks and must match an earlier open brace
|
Download/View intermediate/LengthComparator.java