Unit 2 structure of a java program documentation types of errors example l.jpg
This presentation is the property of its rightful owner.
Sponsored Links
1 / 7

Unit 2 - Structure of a Java Program - Documentation - Types of Errors - Example PowerPoint PPT Presentation

Unit 2 - Structure of a Java Program - Documentation - Types of Errors - Example  Java’s Compiler + Interpreter Editor : Compiler : 7  MyFirstProgram.java  MyFirstProgram.class K This is you… Interpreter Interpreter Interpreter Structure of a Java Program

Download Presentation

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

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Unit 2 structure of a java program documentation types of errors example l.jpg

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


Slide2 l.jpg

Java’s Compiler + Interpreter

Editor

:

Compiler

:

7

MyFirstProgram.java

MyFirstProgram.class

K

This is

you…

Interpreter

Interpreter

Interpreter


Structure of a java program l.jpg

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.


Documentation called comments in computer science l.jpg

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


Types of errors l.jpg

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.


Slide6 l.jpg

The First “Bug”

“(moth) in relay”


Output to the console screen in java the little black screen l.jpg

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);


  • Login