java programming
play

Java Programming Pancakes In one bowl mix: sequence of 1 cup - PowerPoint PPT Presentation

Hello Hello World World What is a program? Definition: a Java Programming Pancakes In one bowl mix: sequence of 1 cup flour instructions telling TOPICS CS 160, Fall Semester 2012 CS 160, Fall Semester 2012 1 tbsp sugar a


  1. Hello Hello World World What is a program? ■ Definition: a Java Programming Pancakes In one bowl mix: sequence of 1½ cup flour instructions telling TOPICS CS 160, Fall Semester 2012 CS 160, Fall Semester 2012 1 tbsp sugar a computer what • Computer Programs to do 1 tsp salt • Using Eclipse 1 tsp baking • Hello World Program • Program Components ■ Analogy: cooking powder recipes CS 160, Summer Semester 2016 1 CS 160, Summer Semester 2016 2 Hello Hello World World Programs ≠ Recipes Programs as Recipes At some point the analogy breaks down: Recipes specify ■ ■ Recipes are read by people What ingredients to use 1. ■ People can make inferences. What to do with them 2. ■ If something goes wrong, people react. Sometimes conditional: “bake until golden brown”, “salt ■ ■ People sometimes make mistakes. to taste” Programs specify ■ ■ Programs are read by machines What information (data) to use 1. ■ Machines do exactly what they are told! What operations to apply 2. ■ No matter how badly things go wrong. Sometimes conditional: “while file is not empty”, “for ■ ■ But, they never make mistakes or get tired. every element in array” CS 160, Summer Semester 2016 3 CS 160, Summer Semester 2016 4

  2. Hello Hello World World Definitions Object-oriented programming ■ program ■ Java programs use objects and methods ■ a set of directions telling a computer exactly what to do ■ An ‘object’ is a collection of code and data that you ■ programming languages treat as a unit. ■ precise languages for specifying sequences of ■ Objects have ‘methods’ – code that implements directions to a computer actions that apply to the object. ■ unlike English -- no ambiguities! no nuances! ■ Objects have ‘members’ – data that is associated ■ algorithm with the object. ■ a sequence of steps to be followed to solve a ■ A Java cooking program might have a line like problem ■ independent of any programming language ‘egg.scramble()’ to scramble an egg… CS 160, Summer Semester 2016 5 CS 160, Summer Semester 2016 6 Hello Hello World World ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ … ■ CS 160, Summer Semester 2016 7 CS 160, Summer Semester 2016 8

  3. Hello Hello Hello World Program World World // HelloWorld // Author: Gareth Halladay // Date: 6/13/2016 // Class: CS160 // Email: gareth@rams.colostate.edu import java.lang.*; public class HelloWorld { public static void main(String[] args) { System. out .println( "Hello World!" ); } } CS 160, Summer Semester 2016 9 CS 160, Summer Semester 2016 10 Hello Hello Import directive World World ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ CS 160, Summer Semester 2016 11 CS 160, Summer Semester 2016 12

  4. Hello Hello World World ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ CS 160, Summer Semester 2016 13 CS 160, Summer Semester 2016 14 Hello Hello World World ▪ ▪ ▪ ▪ ▪ ▪ ▪ CS 160, Summer Semester 2016 15 CS 160, Summer Semester 2016 16

  5. Hello Hello World World ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ CS 160, Summer Semester 2016 17 CS 160, Spring Semester 2016 18 Hello World ▪ CS 160, Summer Semester 2016 19

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend