From ggc
|
01 packagepackage is used to name the directory or folder a class is in intro;
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 application.
09 * @authorthis is the Javadoc tag for documenting who created the source code Jam
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 ConsoleOrParameter
12 {open braces start code blocks and must be matched with a close brace
13 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value add()
14 {open braces start code blocks and must be matched with a close brace
15 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);
16 System.out.println("Enter the first integer.");
17 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 sidescanner.nextInt();
18 System.out.println("Enter the second integer.");
19 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 sidescanner.nextInt();
20 intint is the type for whole numbers and it is short for integer z=this assignment operator makes the left side equal to the right sidex+adds two numbers together or concatenates Strings togethery;
21 System.out.println("The result is "+adds two numbers together or concatenates Strings togetherz);
22 }close braces end code blocks and must match an earlier open brace
23
24 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 add(intint is the type for whole numbers and it is short for integer x, intint is the type for whole numbers and it is short for integer y)
25 {open braces start code blocks and must be matched with a close brace
26 returnreturn means to provide the result of the method and/or cease execution of the method immediately x+adds two numbers together or concatenates Strings togethery;
27 }close braces end code blocks and must match an earlier open brace
28
29 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)
30 {open braces start code blocks and must be matched with a close brace
31 ConsoleOrParameter tester=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ConsoleOrParameter();
32 tester.add();
33
34 Scanner scanner;
35 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);
36 System.out.println("Enter the first integer.");
37 intint is the type for whole numbers and it is short for integer a=this assignment operator makes the left side equal to the right sidescanner.nextInt();
38 intint is the type for whole numbers and it is short for integer b=this assignment operator makes the left side equal to the right sidea*2;
39 intint is the type for whole numbers and it is short for integer c=this assignment operator makes the left side equal to the right sidetester.add(a, b);
40 System.out.println("The result is "+adds two numbers together or concatenates Strings togetherc);
41 }close braces end code blocks and must match an earlier open brace
42 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/ConsoleOrParameter.java