Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introducing Java.

Similar presentations


Presentation on theme: "Introducing Java."— Presentation transcript:

1 Introducing Java

2 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

3 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!

4 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.

5 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.

6 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

7 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.

8 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.

9 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)

10 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

11 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

12 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.

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

14 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

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

16 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

17 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

18 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:

19 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

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

21 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

22 Dr. Java Interface

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

24 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


Download ppt "Introducing Java."

Similar presentations


Ads by Google