From ggc
|
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 java.util.*;
04
05 /**
06 * All about my application.
07 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
08 */
09 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 EqualsDifference
10 {open braces start code blocks and must be matched with a close brace
11 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)
12 {open braces start code blocks and must be matched with a close brace
13 String a=this assignment operator makes the left side equal to the right side"Hello";
14 Scanner scanner=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Scanner(System.in);
15 String b=this assignment operator makes the left side equal to the right sidescanner.next();//"He"+'l'+"lo";
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 sameb)
17 {open braces start code blocks and must be matched with a close brace
18 System.out.println("They refer to the same object.");
19 }close braces end code blocks and must match an earlier open brace
20 elseelse is what happens when the if condition is false
21 {open braces start code blocks and must be matched with a close brace
22 System.out.println("They refer to different objects.");
23 System.out.println("The first object is "+adds two numbers together or concatenates Strings togethera);
24 System.out.println("The second object is "+adds two numbers together or concatenates Strings togetherb);
25 }close braces end code blocks and must match an earlier open brace
26 ifif executes the next statement only if the condition in parenthesis evaluates to true(a.equals(b))
27 {open braces start code blocks and must be matched with a close brace
28 System.out.println("They refer to the same contents.");
29 }close braces end code blocks and must match an earlier open brace
30 elseelse is what happens when the if condition is false
31 {open braces start code blocks and must be matched with a close brace
32 System.out.println("They refer to different contents.");
33 System.out.println("The first object is "+adds two numbers together or concatenates Strings togethera);
34 System.out.println("The second object is "+adds two numbers together or concatenates Strings togetherb);
35 }close braces end code blocks and must match an earlier open brace
36
37 }close braces end code blocks and must match an earlier open brace
38 }close braces end code blocks and must match an earlier open brace
|
Download/View intermediate/EqualsDifference.java