From ggc
|
01 packagepackage is used to name the directory or folder a class is in FA;
02
03
04 /**
05 * This program checks to see ifif executes the next statement only if the condition in parenthesis evaluates to true the methods in Replacer classclass is a group of fields and methods used for making objects work.
06 * @authorthis is the Javadoc tag for documenting who created the source code My Frank Anderson
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 ReplacerTest
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
13 /** source is the string in which replacments will occur. */
14 String source =this assignment operator makes the left side equal to the right side "ababccabababc";
15 /** repl is the expresson which will replace the targed in the source string. */
16 String repl =this assignment operator makes the left side equal to the right side "XXX";
17 /** target is the string to be will be replaced in the source string.*/
18 String target =this assignment operator makes the left side equal to the right side "abc";
19 /**string2 will hold the output from the Replacer classclass is a group of fields and methods used for making objects. */
20 String string2=this assignment operator makes the left side equal to the right side""
21 ;
22
23 Replacer model =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Replacer(target, repl);
24
25 string2 =this assignment operator makes the left side equal to the right side model.getReplaced(source);
26
27 System.out.println("Desired output: abXXXcababXXX");
28 System.out.print(" Actual output: ");
29 System.out.println(string2);
30
31 }close braces end code blocks and must match an earlier open brace
32 }close braces end code blocks and must match an earlier open brace
|
Download/View FA/ReplacerTest.java