02_helloworld - 1 CS101: Introduction to Computer Science...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 CS101: Introduction to Computer Science • Slides adapted from Sedgewick and Wayne • Copyright © 2007 • http://www.cs.Princeton.EDU/IntroCS 1.1 Your First Program 2 Why Programming? Idealized computer. "Please simulate the motion of a system of N heavenly bodies, subject to Newton's laws of motion and gravity." Prepackaged software solutions. Great, if it does exactly what you need. Computer programming. Art of making a computer do what you want. Ada Lovelace Analytic Engine 3 Languages Machine languages. Tedious and error-prone. Natural languages. Ambiguous and hard for computer to parse. High-level programming languages. Acceptable tradeoff. [ real newspaper headlines, compiled by Rich Pattis ] Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to human beings what we want a computer to do. - Donald Knuth Kids Make Nutritious Snacks. Red Tape Holds Up New Bridge. Police Squad Helps Dog Bite Victim. Local High School Dropouts Cut in Half. 4 Why 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. … James Gosling http://java.net/jag $100 billion, 5 million developers 2 5 Why Java? Java features. Widely used. Widely available. Embraces full set of modern abstractions. Variety of automatic checks for mistakes in programs. Caveat. There are only two kinds of programming languages: those people always [gripe] about and those nobody uses. - Bjarne Stroustrup 6 Why Java? Java features. Widely used. Widely available. Embraces full set of modern abstractions. Variety of automatic checks for mistakes in programs. Caveat. No perfect language. Our approach. Minimal subset of Java. Develop general programming skills that are applicable to: C, C++, C#, Perl, Python, Ruby, Matlab, Fortran, Fortress, … 7 A Rich Subset of the Java Language Primitive Numeric Types != == >= <= < > -- / + % - ++ * Integer.parseInt() Double.parseDouble() Parsing Math.max() Math.min() Math.pow() Math.sqrt() Math.PI Math.abs() Math.log() Math.sin() Math Library Math.exp() Math.cos() System.out.println() System.out.print() System.out.printf() System for if Flow Control while else ! || true Boolean && false ; , ( { Punctuation ) } a[i] new a.length Arrays matches() charAt() length() + String compareTo() "" boolean char long int Built-In Types String double equals() toString() main() new public class Objects private static CS101: Introduction to Computer Science • Slides adapted from Sedgewick and Wayne • Copyright © 2007 • http://www.cs.Princeton.EDU/IntroCS Create, Compile, Execute 3 9 Programming in Java Programming in Java....
View Full Document

Page1 / 10

02_helloworld - 1 CS101: Introduction to Computer Science...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online