Creating Your First Computer Program in Java Margaret Yau.
-
Upload
damian-bond -
Category
Documents
-
view
213 -
download
0
Transcript of Creating Your First Computer Program in Java Margaret Yau.
![Page 1: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/1.jpg)
Creating Your First Computer Program in Java
Margaret Yau
![Page 2: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/2.jpg)
![Page 3: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/3.jpg)
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
![Page 4: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/4.jpg)
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
![Page 5: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/5.jpg)
Creating Your First Program in
• Java– High-level– Object-oriented programming (OOP) language– Platform-independent– Free and open-source
![Page 6: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/6.jpg)
Three Important Parts of Computer Programming
• Coding• Compiling• Testing
![Page 7: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/7.jpg)
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.
![Page 8: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/8.jpg)
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
![Page 9: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/9.jpg)
<class name>.java
![Page 10: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/10.jpg)
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
![Page 11: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/11.jpg)
Compiling Your Java Program
Hello.java javac Hello.class
Source Code Compiler Object Code
javac <source file name>
![Page 12: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/12.jpg)
3. Testing• Execute the program
• Find software bugs (error, mistake, or failure)
• Verify that the program meets its requirements
Machine
Processor
Object code
![Page 13: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/13.jpg)
3. Testing• Execute the program• Find software bugs (error, mistake, or failure)
• Verify that the program meets its requirements
![Page 14: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/14.jpg)
Executing (Running) Your Java Program
java <class name>
Yay! I ran my first Java program!
![Page 15: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/15.jpg)
You have coded, compiled, and tested your first computer program
in Java.
![Page 16: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/16.jpg)
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
![Page 17: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/17.jpg)
And you may be the next …
Mark ZuckerbergFacebook
Bill GatesMicrosoft
Steve JobsApple
Larry Page Sergey Brin
![Page 18: Creating Your First Computer Program in Java Margaret Yau.](https://reader035.fdocuments.in/reader035/viewer/2022070415/56649f2a5503460f94c44f91/html5/thumbnails/18.jpg)
Questions?