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.io.*;
04 importimport means to make the classes and/or packages available in this program java.util.*;
05 importimport means to make the classes and/or packages available in this program wiki.*;
06 //end auto-imports
07
08
09 /**
10 * All about my application.
11 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
12 */
13 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 ReadAndPrint
14 {open braces start code blocks and must be matched with a close brace
15 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)
16 {open braces start code blocks and must be matched with a close brace
17 System.out.println("Maze:");
18 Scanner scanner=this assignment operator makes the left side equal to the right sidenullnull is the value used to refer to a non-existant object;
19 trytry is for executing a code block that may experience exceptions (errors)
20 {open braces start code blocks and must be matched with a close brace
21 scanner=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Scanner(Wiki.getInputStream("Maze2.txt"));
22 }close braces end code blocks and must match an earlier open brace
23 catchcatch means to handle an exception that may occur(IOException e)
24 {open braces start code blocks and must be matched with a close brace
25 System.out.println("Had problems making scanner: "+adds two numbers together or concatenates Strings togethere);
26 }close braces end code blocks and must match an earlier open brace
27 String total=this assignment operator makes the left side equal to the right side"";
28 System.out.println("Reading...");
29 whilewhile is a looping structure for executing code repeatedly(scanner.hasNext())
30 {open braces start code blocks and must be matched with a close brace
31 total+=this increases the variable on the left by the value on the rightscanner.nextLine()+adds two numbers together or concatenates Strings together"\n";
32 }close braces end code blocks and must match an earlier open brace
33 System.out.println(total);
34 }close braces end code blocks and must match an earlier open brace
35 }close braces end code blocks and must match an earlier open brace
|
Download/View intro/ReadAndPrint.java