From ggc
|
01 packagepackage is used to name the directory or folder a class is in intro;
02
03
04 /**
05 * All about my application.
06 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
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 StringManipulations
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 String phrase=this assignment operator makes the left side equal to the right side"Hello Java WIDE";
13 String phrase2=this assignment operator makes the left side equal to the right side"Goodbye and good luck Intro Programming";
14 System.out.println(phrase.substring(6, 10));
15 System.out.println(phrase.charAt(1));
16 System.out.println(phrase.length());
17 System.out.println(phrase.indexOf("WIDE"));
18 System.out.println(phrase.indexOf("C++"));
19 intint is the type for whole numbers and it is short for integer start=this assignment operator makes the left side equal to the right sidephrase2.indexOf("Intro");
20 String result=this assignment operator makes the left side equal to the right sidephrase.substring(phrase.indexOf("Hello"), 6)+adds two numbers together or concatenates Strings togetherphrase2.substring(start, phrase2.length());
21 System.out.println(result);
22 }close braces end code blocks and must match an earlier open brace
23 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/StringManipulations.java