Upload
damian-bond
View
213
Download
0
Tags:
Embed Size (px)
Citation preview
Creating Your First Computer Program in Java
Margaret Yau
Impacts of Software
- Microsoft: the world’s largest software company- company worth $36 billion (2008)
- over 400 million copies of Windows XP sold
- the largest social networking site- company worth $3.75 – 5 billion- more than 200 million active users
Can you even imagine a day without using software?
- over 21 million iPhones sold- 50,000 applications available for download
The InternetWWW
- over 109.9 million active websites- estimated 1.5 billion Internet users
(~ 5 x U.S. Population)- 14.3 billion searches by Americans in May 09
Computer programming is fun and powerful
"I'm not coming down for dinner, didn't you read my blog ?!?!"
And it is not just for nerds
Creating Your First Program in
• Java– High-level– Object-oriented programming (OOP) language– Platform-independent– Free and open-source
Three Important Parts of Computer Programming
• Coding• Compiling• Testing
1. Coding
• Source Code: collection of statements or declarations written in some human-readable computer programming language
• A high-level way of communicating with the computer
Java: System.out.println(“How are you?");
English: Print the string “How are you?” to the computer screen.
class Hello {
public static void main ( String[] args ) {
System.out.println("Hello World!");
} }
Define a type of object (class)
Class name
Define the main behavior (method)
A statement that prints “Hello World!” to the main output device
Coding Your “Hello World!” Java Program
<class name>.java
2. Compiling
• A compiler translates source code in a high-level language to code in a low-level language that a particular type of machines understands (often binary form)
Source code(Hello.java)
Compiler(javac)
Object code(Java bytecodes:
Hello.class)
class Hello { public static void main { System.out.println…
10001010 0101001101010011 1111010111110101 1001010110010101 10010101
Compiling Your Java Program
Hello.java javac Hello.class
Source Code Compiler Object Code
javac <source file name>
3. Testing• Execute the program
• Find software bugs (error, mistake, or failure)
• Verify that the program meets its requirements
Machine
Processor
Object code
3. Testing• Execute the program• Find software bugs (error, mistake, or failure)
• Verify that the program meets its requirements
Executing (Running) Your Java Program
java <class name>
Yay! I ran my first Java program!
You have coded, compiled, and tested your first computer program
in Java.
What’s Next• Software can be designed to perform almost
anything computable.• Observe and ask what people need, and use your
imagination…
e.g. program - that really understands natural language- that computes one quadrillion (1015) digits of π- that reads your mind- that creates original and artistic songs and poetry
And you may be the next …
Mark ZuckerbergFacebook
Bill GatesMicrosoft
Steve JobsApple
Larry Page Sergey Brin
Questions?