Lesson1-Introduction To Java
Lesson1-Introduction To Java
Course content
• Introduction to Java
• Java Basics
• Expressions
• Arrays
• Control Flow
• Classes
• Inheritance
• Polymorphism
• Binding
• Abstract Classes
• Graphical User Interface
References
• The textbook is Deitel & Deitel, Java How to Program (late
objects), 10th Edition, Prentice Hall (2014).
• Web Resources
Course Rationale
• Multi-line comments
• All text between start and end of comment is ignored e.g.
/* comment goes
in this space, here */
• Javadoc comments
• Delimited by /** and */.
• Enable you to embed program documentation directly in your programs.
• The javadoc utility program reads Javadoc comments and uses them to
prepare program documentation in HTML format.
/** documentation */
2. A class definition:
• A class definition: Java programs include at least a class
definition such as public class HelloWorld. The class extends
from the first opening curly brace { to the last closing curly
brace }
3. The main() method:
• The main() method: a method is a collection of
programming statements that have been given a name
and that execute when called to run. Methods are also
delimited by curly braces
• all Java applications (not applets) must have a class (only
one) with a main() method where execution begins;
• the main() method is preceded by the words public
static void called modifiers;
• the main() method always has a list of command line
arguments that are passed to the program main(String[]
args) (which we are going to ignore for now)
RECUP
4. Statements
• Statements are
• instructions to the computer to determines what to do
• end with a semicolon ';'
• In this example there is only one statement
System.out.println("Hello world"); to print a
message and move the cursor to the next line
Reserved words
• class, static, public, void have all been reserved by the
designers and they can't be used with any other meaning
Case sensitive
• Java compilers are case sensitive, meaning that they see lower
case and upper case differently.
Programming Errors
• Programming errors can be divided into:
• Compilation errors: are detected by the compiler at
compilation time. The executable is not created.
• Execution errors: appear when the program runs.
Typically execution stops when an exception such as
this happens, it is possible to handle these errors
• Logical errors: the program compiles and runs with no
problems but gives out wrong results
• END