1 / 2

Ch1 Cont.

Ch1 Cont. 1.6 Compiling a Simple Program : Lets dissect the simple “Hello World” program: public class Hello{ public static void main(String[ ] args ){ System.out.println (“Hello, World”); } }

weylin
Download Presentation

Ch1 Cont.

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ch1 Cont. • 1.6 Compiling a Simple Program: • Lets dissect the simple “Hello World” program: public class Hello{ public static void main(String[ ] args){ System.out.println(“Hello, World”); } } • Points of Importance ( In General – not necessarily applicable in “Hello World”): • Classes are the Building blocks in Java! • Classes are written to represent entities in the Real World. ADT “BankAccount”! • Class variables (Objects of that class) manipulate their data (instance fields) by calling associated methods. NOTE – EITHER BUCKLE UP <or> gloss over – TBD! • Methods are functions of a class -> usually invoked by dot.notation( ). • Classes by convention start in UpperCase. • Every Java application contains a main method. Basically the main program. • General Layout conventions: • Tab over every level of abstraction (top-down design indentation) • Line up ending brackets} with its starting code. • Give your code “air” in a uniform manner. • Your code should be readable. • Lets dissect the above code: • “Hello World” is a ___________, and also a __________ of the print method. • Syntax vs Semantics.

  2. 1.7 Errors • A compile-time or syntax error is a violation of the grammatical rules of the particular language you are programming in. • Syntax errors occur during the compilation process. • Common syntax errors: • Misspelled words – Java is case-sensitive. • Omitting semi-colons. • A run-time or logic error occurs when the program compiled correctly, but the program either crashes during execution or gives incorrect results. • Test your answers using pencil & paper! • Using various methods along with the Debugger will allow you to find logic errors. • 1.8 The Compilation Process. • Look at the p26 diagrams. • Lets log on (StudentAccessCode & ID_Number) • BlueJ public class Hello { public static void main(String[ ] args) { System.out.println(“Hello, World”); } }

More Related