Why and How to Start Programming in Java: A Comprehensive Guide, Slides of Computer Programming

Learn the basics of programming with java, a widely-used and versatile high-level programming language. Discover why programming is important, choose java as your language, and get started with your first 'hello, world' program. Understand java features, syntax, and built-in types.

Typology: Slides

2011/2012

Uploaded on 07/15/2012

sachdew
sachdew 🇮🇳

4

(6)

37 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1.1 Your First Program
!
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Why and How to Start Programming in Java: A Comprehensive Guide and more Slides Computer Programming in PDF only on Docsity!

1.1 Your First Program

!

2

Why Programming?

Why programming? Need to tell computer what to do.

Prepackaged software solutions. Great, they do exactly what you want.

Programming. Enables you to make a computer do anything you want.

Ada Lovelace Analytic Engine “Please simulate the motion of N heavenly bodies, subject to Newton’s laws of motion and gravity.” well, almost anything [stay tuned]

4

Why Program?

Why program?

! A natural, satisfying and creative experience.

! Enables accomplishments not otherwise possible.

! Opens new world of intellectual endeavor.

First challenge. Learn a programming language.

Next question. Which one?

Naive ideal. A single programming language.

5

Our Choice: Java

Java features.

! Widely used.

! Widely available.

! Embraces full set of modern abstractions.

! Variety of automatic checks for mistakes in programs.

Java economy.

! Mars rover.

! Cell phones.

! Blu-ray Disc.

! Web servers.

! Medical devices.

! Supercomputing.

$100 billion, 5 million developers

James Gosling

http://java.net/jag

7

A Rich Subset of the Java Language

Primitive Numeric Types !=

Integer.parseInt() Double.parseDouble() Parsing Math.min() Math.max() Math.sqrt() Math.pow() Math.abs() Math.PI Math.log() Math.sin() Math Library Math.exp() System.out.println() Math.cos() System.out.print() System.out.printf() System for if Flow Control while else !

true Boolean && false , ;

Punctuation )

a[i] new a.length Arrays charAt() matches() length()

String compareTo()

char boolean long int Built-In Types String double final toString() new main() public class Objects private static

Assignment

Hello, World

10

Programming in Java

Programming in Java.

! Create the program by typing it into a text editor, and

save it as HelloWorld.java.

! Compile it by typing at the command-line:

javac HelloWorld.java.

! This creates a Java bytecode file named: HelloWorld.class.

command-line

% javac HelloWorld.java

(or click the Compile button in DrJava)

11

Programming in Java

Programming in Java.

! Create the program by typing it into a text editor, and

save it as HelloWorld.java.

! Compile it by typing at the command-line:

javac HelloWorld.java.

! Execute it by typing at the command-line:

java HelloWorld.

% javac HelloWorld.java

% java HelloWorld

Hello, World

command-line

13

Dr. Java

compile

14

Dr. Java

command-line argument