Lecture Notes CS 101 from 9/2/2010 INtro to Java Programming Elements Steps to writing a Java Program 1. Edit the Source code file 2. Run the Java Compiler to translate the Source Code File to an "Executable File" which is a file that the computer can run. 3. Run the Executable File Two primary classifications of Errors when writing a program. 1. Syntax Error - program is not written using proper "punctution" 2. Logic Error - program does not perform as desired Elements in a Java Program Comments - items placed in a program for the human readers/writer to look at. This information is ignored by the compiler. This information is normally used to briefly describe what the program is attempting to do. End of Line Comment // Block Comments Start with a /* End with a */ Class Name - The name of the file must match the name of the public class in that file Output statement - can come in many forms one form is the System.out.println() method. The information contained between the parentheses is displayed in the console window as output. Variables - words that identify "mailboxes" in memory. The words must start with a letter and then can contain letters, digits or the underscore character Valid Variable names: index, value1, i, helloThere, maxValue, here_is_another_variable, sdfsd, average, a1b2c3 invalid variable name: 23rdValue, value^%$ variable are created with a variable declaration statement int value1; int value2, value3; int value4 = 0; General Syntax: ; Assignment statements - allow a value in a variable to be changed. General Syntax: = ; value1 = 35; value2 = 10 * 3; value3 = value1; value4 = value3 + 8;