From ggc
|
01
02 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
03
04 /**
05 * All about my application here.
06 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
07 */
08 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 ComparisonExample
09 {open braces start code blocks and must be matched with a close brace
10 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)
11 {open braces start code blocks and must be matched with a close brace
12 intint is the type for whole numbers and it is short for integer x=this assignment operator makes the left side equal to the right side6;
13 intint is the type for whole numbers and it is short for integer y=this assignment operator makes the left side equal to the right side6;
14 Point2D.Double pointA;
15 pointA=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Point2D.Double(x, y);
16 Point2D.Double pointB;
17 pointB=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Point2D.Double(x+adds two numbers together or concatenates Strings together1, y);
18 pointB=this assignment operator makes the left side equal to the right sidepointA;
19 pointA.x=this assignment operator makes the left side equal to the right side10;
20 System.out.println("x of pointB is "+adds two numbers together or concatenates Strings togetherpointB.x);
21 System.out.println("x of pointA is "+adds two numbers together or concatenates Strings togetherpointA.x);
22
23 ifif executes the next statement only if the condition in parenthesis evaluates to true(pointA==this is the comparison operator which evaluates to true if both sides are the samepointB)
24 System.out.println("Same Memory Location");
25 elseelse is what happens when the if condition is false
26 System.out.println("Different Memory Location");
27 ifif executes the next statement only if the condition in parenthesis evaluates to true(pointA.equals(pointB))
28 System.out.println("Same Memory Contents");
29 elseelse is what happens when the if condition is false
30 System.out.println("Different Memory Contents");
31
32 }close braces end code blocks and must match an earlier open brace
33 }close braces end code blocks and must match an earlier open brace
|
Download/View ComparisonExample.java