|
01 packagepackage is used to name the directory or folder a class is in intermediate;
02
03 importimport means to make the classes and/or packages available in this program wiki.Wiki;
04 importimport means to make the classes and/or packages available in this program java.awt.*;
05 importimport means to make the classes and/or packages available in this program java.util.*;
06
07 /**
08 * All about my application here.
09 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
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 ComparatorExample
12 {open braces start code blocks and must be matched with a close brace
13 staticstatic means that an instance is not required for access (class level access) classclass is a group of fields and methods used for making objects CompareByX implementsimplements means providing method bodies for the methods declared in the corresponding interface Comparator<Point>
14 {open braces start code blocks and must be matched with a close brace
15 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(Point left, Point right)
16 {open braces start code blocks and must be matched with a close brace
17 returnreturn means to provide the result of the method and/or cease execution of the method immediately left.x-right.x;
18 }close braces end code blocks and must match an earlier open brace
19
20 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false equal(Point left, Point right)
21 {open braces start code blocks and must be matched with a close brace
22 returnreturn means to provide the result of the method and/or cease execution of the method immediately left.x==this is the comparison operator which evaluates to true if both sides are the sameright.x;
23 }close braces end code blocks and must match an earlier open brace
24 }close braces end code blocks and must match an earlier open brace
25
26 staticstatic means that an instance is not required for access (class level access) classclass is a group of fields and methods used for making objects CompareByY implementsimplements means providing method bodies for the methods declared in the corresponding interface Comparator<Point>
27 {open braces start code blocks and must be matched with a close brace
28 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(Point left, Point right)
29 {open braces start code blocks and must be matched with a close brace
30 returnreturn means to provide the result of the method and/or cease execution of the method immediately left.y-right.y;
31 }close braces end code blocks and must match an earlier open brace
32
33 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false equal(Point left, Point right)
34 {open braces start code blocks and must be matched with a close brace
35 returnreturn means to provide the result of the method and/or cease execution of the method immediately left.y==this is the comparison operator which evaluates to true if both sides are the sameright.y;
36 }close braces end code blocks and must match an earlier open brace
37 }close braces end code blocks and must match an earlier open brace
38 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args)
39 {open braces start code blocks and must be matched with a close brace
40 Point[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays points=this assignment operator makes the left side equal to the right side{open braces start code blocks and must be matched with a close brace
41 newnew is used to create objects by calling the constructor Point(4, 5),
42 newnew is used to create objects by calling the constructor Point(3, 8),
43 newnew is used to create objects by calling the constructor Point(5, 2),
44 newnew is used to create objects by calling the constructor Point(1, 10)
45 }close braces end code blocks and must match an earlier open brace;
46 Arrays.sort(points, newnew is used to create objects by calling the constructor CompareByX());
47 Wiki.out.println("Sorted by x:");
48 forfor is a looping structure for repeatedly executing a block of code(Point p: points)
49 Wiki.out.println(p);
50
51 Arrays.sort(points, newnew is used to create objects by calling the constructor CompareByY());
52 Wiki.out.println("Sorted by y:");
53 forfor is a looping structure for repeatedly executing a block of code(Point p: points)
54 Wiki.out.println(p);
55
56 Wiki.out.println("Add your code here.");
57 }close braces end code blocks and must match an earlier open brace
58 }close braces end code blocks and must match an earlier open brace
|