Introducing Java.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Programming for Beginners
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. OBJECTIVES FOR THIS UNIT Upon completion of this unit, you should be able to: Explain the Java virtual machine.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. GCOC – A.P. Computer Science A College Board Computer Science A Topics Covered Program Design - Read and understand.
 2005 Pearson Education, Inc. All rights reserved Introduction.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction To Computers and Programming Lecture 2: Your first program Professor: Evan Korth New York University.
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
How to Create a Java program CS115 Fall George Koutsogiannakis.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
C programming Language and Data Structure For DIT Students.
Marlene Galea.  The JDK (Java Development Kit)  An IDE (Integrated Development Environment) ◦ Different IDEs include:  JCreator  NetBeans  BlueJ.
Getting Started with Java
Programming a computer. What does programming a computer mean ? Programming a computer: Since a computer can only execute machine instructions (encoded.
Using C Programming Language.  The programs that run on a computer are referred to as software.  You’ll learn key programming methodology that are enhancing.
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
Chapter 1 Introduction.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
Chapter 1: Creating Java Programs
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
Programming Lifecycle
© 2006 Pearson Education 1 Obj: cont 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 –
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Computer Programming TCP1224 Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
Input, Output, and Processing
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
© 2004 Pearson Addison-Wesley. All rights reserved ComS 207: Programming I Instructor: Alexander Stoytchev
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
1 WELCOME TO CIS 1068! Instructor: Alexander Yates.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Java FilesOops - Mistake Java lingoSyntax
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Objective Write simple computer program in C++ Use simple Output statements Become familiar with fundamental data types.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Software Engineering Algorithms, Compilers, & Lifecycle.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Installing Java on a Home machine
Working with Java.
Before You Begin Nahla Abuel-ola /WIT.
CSC201: Computer Programming
Getting Started with C.
Java programming lecture one
Installing Java on a Home machine
Chapter 1 Coding Introduction.
String Output ICS 111: Introduction to Computer Science I
Fundamentals of Programming
Introduction CSC 111.
Computer Programming-1 CSC 111
Introduction to Programming - 1
Instructor: Alexander Stoytchev
Presentation transcript:

Introducing Java

What is Programming? A program is a list of instructions that is executed by a computer to accomplish a particular task. Creating those instructions is programming Developing a Program is a circular process. The process is known as the Program Development Life Cycle and it has four key steps that repeat themselves: Analyze the problem Design a program to solve the problem Code the program Test the program

Programming Activity Provide an algorithm to make a peanut butter and jam sandwich. An algorithm is a precise list of instructions Use the PDLC to create the perfect sandwich!

Basic Programming Concepts Key Concepts and Key Vocabulary Pseudocode is used to plan out the logic of a computer program, using English words and phrases. Input refers to information that is accepted into the program from the user or other sources. Variables represent values within a program. Constants are values used within a program. The value of a constant does not change (i.e., it is constant) throughout the program.

How programming languages work Computers think in ones and zeros and we have to find a way of communicating with them Machine language is the way the computer understands our instructions. The machine language needs to translate to 1 and 0. Fortunately, we do not have to write instructions to computers in machine language. Instead, we can write instructions in a programming language. A programming languages resemble the structure and syntax of human language, not ones and zeroes. programming languages automate instructions; one programming language instruction can cover many machine language instructions.

Developing Programs A software programming language is a type of language that is specifically used to give instructions to a computer. Java is a programming language. It has a vocabulary and grammar rules just like the English language. The vocabulary includes special words like “class” which has a very specific meaning (more on that later) The grammar is called syntax and there are certain rules and ways of writing things that must be observed in order for the program to work

Translating Programs Once you have developed or written your program you want the computer to be able to perform the instructions you gave it. If you recall the computer only understands bits or 0s and 1s. A computer does not understand the instructions from your language. It needs to translate the code into 0s and 1s.

Running a Program Translating the program is often referred to as compiling or running a program Compiling a program The compiler translates the source code (your program) into machine language instructions The machine language is the language that computers understand (0s and 1s) also called bytecode The way a program is run is different for different languages and systems. Java has its own way – something called a Java Virtual Machine (JVM) which ones program to work on different operating systems without changing the code.

Developing Java Programs To be able to develop and run Java programs you will need three things: 1. A Java Runtime Environment(JRE) 2. The Java Software Development Kit (JDK) 3. An Integrated Development Environment (IDE)

Java Runtime Environment (JRE) The JRE runs Java Applications on your computer system. This is often already installed on a computer system for Java Applications that you may already be using If you install the Java Development Toolkit, you will not need to install the JRE, because it is included

Java Development Toolkit (JDK) The Java Development Toolkit is a the development environment required for building applications, applets and components of Java programs. You cannot create programs with Java unless you have this piece of software installed. It is called a toolkit because it includes tools for developing and testing programs for Java. The latest edition is JDK version 7. You can download a copy from www.oracle.com/technetwork/java/javase/downloads/index.html

Integrated Development Environment (IDE) The Integrated Development Environment is a software application that is designed to assist the user in developing Java programs. There are many such applications available. The JDK is an example of and IDE. The JDK includes a compiler, and interpreter and an API (Application Programming Interface) to enable you to write, run and test the programs you are creating. However, as all inputs are through a command line interface, it is not the most user friendly way to get started with Java.

Dr. Java The IDE we are going to use in this course is going to be Dr. Java It can be downloaded at http://drjava.org It is a straightforward program that lets you quickly set up, write, run and test your program

Analyzing the Code The Class The Method Statements Each of the related instructions, or statements, which belong to the class are contained within the body of that class. A class starts with a left curly brace, { and ends with a right curly brace }. The Method Java executes or runs the instructions by methods. There has to be at least one method in any Java program – known as the main method. Statements Each statement usually ends with a semicolon ; Statements are the instructions for the computer

Before we begin Expression and Statements The main parts of a program Comments Escape Characters

Expressions & Statements A statement is a simple command that causes something to happen An expression is any sequence of objects and operations that combine to produce a value

Main Parts of the Program Consider the 3 main components of a computer program: INPUT: is the data we need to use PROCESS: what we do with the data OUTPUT: the solution to the problem

Consider the 3 main components of a computer program: INPUT: is the data we need to use PROCESS: what we do with the data OUTPUT: the solution to the problem Think of a variable not only as a value that can changed but also as a storage location in memory:

Comments *good programming practice Before we begin programming we need to know what is going on Comments are not part of the program but explain what the program is going to do Comments need to be included in every program!!! There are three different kinds of comments in Java One Line Multiple Lines Computer/Human Readable

Comments syntax One Line Multiple Line Computer Readable Line //place comment here Multiple Line /*place comments here*/ Computer Readable Line /** insert comments here**/

Escape Characters Special Characters that perform the following tasks: '\n' newline character '\t' horizontal tab '\v' vertical tab '\f' form feed '\a' alert/bell '\\' backslash char '\'' apostrophe '\"' double quote

Dr. Java Interface

Program Sample Compile first Run next This is where you write your program Always save program as: <name>.java Output

The Java Program It seems tradition in any programming book the first code output example is “Hello World” Code are the instructions in the programming language The code to output “Hello World” in Java is: class Hello { public static void main (String[] args) System.out.println(“Hello,world!”); } Name of the class all Java programs start with class-defines the function Main method must always be included in any Java program Brace brackets indicates beginning and end of class, Print command System: calls method out: output println: to print “Hello World” – String (whatever you want printed out. Brace brackets indicates beginning and end of method