Title: Programming Principles using
1Programming Principles using
2Programming Principles using Java
- Course Organiser Michael Ulman
- Tower Hill room 217
- email m.ulman_at_londonmet.ac.uk
- phone 0207 320 1723
3Course Outline
- Introduction to Java and Object Oriented Concepts
- Java Virtual Machine
- BlueJ
- Identifiers, Data Types Variables
- Arithmetic programming
- Decisions
- Control Structures
- Methods
- Applets
- Java GUI
4Assessment
- Coursework 12
- 4 exercise solutions (3 each)
- a major exercise is one of these exercises
- Final Examination 88
- 2 hours
- section A a test of understanding of elementary
Java - section B based on the major exercise solution
5Textbook
6Other Books
- Teach Yourself Java Chris Wright
- Java Simplified Adam Shaw
- Introductory Java David Parsons
7Programming is about creating Software
- What is software?
- Where do we find software?
- what kinds of software are there?
- This is a PROGRAMMING course first.
- Learning to program is a complex skill, we are
going to learn some of the basics
8Programs
- What is a Program ?
- Programs Data Algorithms
- Algorithm set of step by step instructions
- e.g a Recipe
- Data as Input, Algorithm Processes the data and
the Results are Output
9first Java program source code
public class Hello public static void main
(String args) System.out.println(Hello
World)
10Programming Languages
- Machine Code language the processor understands
- each processor has its own instruction set
- written in binary 0s 1s
- 1111010011010100
11Program Development
source code
compilation
machine code
12Java History
- Inventor James Gosling at Sun Microsystems in
1991 as part of Stealth, then Green Projects - Originally called Oak
- For use on large distributed, network of
consumer electronic devices all talking to each
other
13Java History
- Javas first proposed use came in 1994 as an
operating system for Interactive TV, this
failed. - What came along that could use such a language ?
One that - Works on many different platforms
- Works on networked computers
- Where security and reliability are important
14Java History
- World Wide Web applications for the Web
- Java was announced at SunWorld 95
- Netscape announced it would incorporate Java
support in their browser, Microsoft followed suit
with Internet Explorer
15Microsoft the dominant platform
16Java platform independent
17James Gosling Javas inventor
18Java is fun
19Java Virtual Machine
- JVM is a program that acts like a processor on
which Java programs run - JVM is what makes Java programs portable
- Write once run anywhere
20Java Platform Independence
C source file Hello.c
C source file Hello.c
Java Source file Hello.java
COMPILATION javac Hello.java
COMPILATION
BYTECODE Hello.class
INTERPETATION on the Java Virtual Machine java
Hello
MACHINE CODE
MACHINE CODE
MACHINE CODE
MACHINE CODE
21Java Development Kit
- JDK is Suns free command line development
environment - Java source files have a .java extension
- Use javac myclass.java to compile your sourcefile
to bytecode - Results in a file with a .class extension
- To run your Java program on its interpreter java
myclass
22first Java program
public class Hello public static void main
(String args) System.out.println(Hello
World)
23second Java program
- import javax.swing.JOptionPane
- public class Welcome
- public static void main(String args)
- JOptionPane.showMessageDialog(
- null, Welcome\nto\nJava\nProgramming!,
JOptionPane.PLAIN_MESSAGE) - System.exit(0)
-
24Output of Welcome program
25Running our first program
- project Welcome is in U\CS1F03C\Week1\Welcome
- copy project Welcome to the X or a floppy on A
- To run BlueJ go to L\BlueJ
- click on BlueJ.exe
26BlueJ
L\BlueJ - click on BlueJ.exe
27BlueJ - opening a project
28BlueJ projects
29BlueJ Design Window - Welcome class
30BlueJ Editor Window source code
31BlueJ selecting a method
32BlueJ method call
33BlueJ output window
34BlueJ
- www.BlueJ.org
- Getting Started with Java
- Getting Started at Home with Java
- in U\CS1F03C
35(No Transcript)