Unit 2 - Structure of a Java Program - Documentation - Sorts of Mistakes - Illustration - PowerPoint PPT Presentation

unit 2 structure of a java program documentation types of errors example l.
Skip this Video
Loading SlideShow in 5 Seconds..
Unit 2 - Structure of a Java Program - Documentation - Sorts of Mistakes - Illustration PowerPoint Presentation
Unit 2 - Structure of a Java Program - Documentation - Sorts of Mistakes - Illustration

play fullscreen
1 / 7
Download
Download Presentation

Unit 2 - Structure of a Java Program - Documentation - Sorts of Mistakes - Illustration

Presentation Transcript

  1. Unit 2- Structure of a Java Program- Documentation- Types of Errors- Example

  2. Java’s Compiler + Interpreter Editor : Compiler : 7  MyFirstProgram.java  MyFirstProgram.class K This is you… Interpreter Interpreter Interpreter

  3. Structure of a Java Program For Unit 2, you will be writing the most basic form of Java Programs. They look like this: publicclass SomeName { public static void main (String [ ] args) { statement; statement; statement; … } } This name must match the filename. This is where the program starts. It looks for the “main method” and begins here.

  4. Documentation(called “comments” in Computer Science) // Name: // Last Changed: // Description: What does this program do. publicclass SomeName { public static void main (String [ ] args) { statement; … } } At the top of each file, I would like you have the following documentation

  5. Types of Errors Syntax Error: an error that the compiler gives you. This could be a missing “;” misspelled word, missing (), etc Logic Error: an error that causes the program to not work correctly. A.K.A. “Software Bugs” Example: If the program required you to draw an octagon and you drew a hexagon.

  6. The First “Bug” “(moth) in relay”

  7. Output to the console screen in Java (the little black screen) • Two output methods: • System.out.println(someString); • System.out.print(someString); Examples String firstName = “Mike”; String lastName = “Efram”; System.out.println(firstName); System.out.println(lastName); System.out.print(firstName); System.out.print(lastName); System.out.println(firstName + “ ” + lastName);