JavaUnit2
JavaUnit2
Introduction to Java
Simon Powers
[email protected]
CSCU9P1
Attendance, engagement and success
• We will follow up to offer support and discuss your engagement with teaching and learning
XV-FE-UZ
Lecture goals
1. Understand how computers run programs
2. Meet your first Java program
3. Meet the BlueJ programming environment
4. Learn about compile-time and run-time errors
Computer programs
• A program is a precise sequence of instructions
• Each instruction is very simple
• There are many different programming
languages
• A program to get a robot to draw a square might
look like:
REPEAT 4 times:
(1) Go forward 100 steps
(2) Turn left 90 degrees
The origin of computer programming
• Early computers were not known for their flexibility
• The program was built into the processor
• Some computers allowed the processor to be conveniently rewired
Where might you find the instructions for a computer program when the computer is
switched off?
a) SSD / hard disk b) RAM
Programming languages
• The instructions in a program need to be unambiguous
• So languages like English are not suitable!
• We could write our programs with primitives that directly control the
processor…
A machine
language
program to
print out the
current date
and time
Higher-level languages
• Fortunately we don’t have to write
in the language of the processor….
• It is platform-independent
Your programming environment
• Programs are usually written in an Integrated Development (IDE).
• We will use the BlueJ IDE in this module
• Later modules will use the Eclipse IDE
• You enter your program in the source code editor, which helps you by:
• Colouring parts of the code
• Showing line numbers
• Auto formatting
• IDEs also have an output window, and a debugger.
The BlueJ IDE
Main BlueJ Window
Editor
Output
Your first program
• Display the message “Hello World” on the screen