Download Java Programming Part I Slide I Welcome to Java Programming Part

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Java Programming Part I
Slide I
Welcome to Java Programming Part I
Slide 2
During this presentation we will discuss the following items:
The Java programming language, Program Development and Object Oriented Programming
First let’s discuss The Java Programming Language.
Slide 3
A programming language specifies the words and symbols that we can use to write a program
A programming language employs a set of rules that dictate how the words and symbols can be put
together to form valid program statements
The Java programming language was created by Sun Microsystems, Inc.
It was introduced in 1995 and its popularity has grown quickly since
Slide 4
In the Java programming language:
A program is made up of one or more classes
A class contains one or more methods
A method contains program statements
A Java application always contains a method called main
Slide 5
Let’s look at the Lincoln.java example
public class Lincoln
{
//----------------------------------------------------------------// Prints a presidential quote.
//----------------------------------------------------------------public static void main (String[] args)
{
System.out.println ("A quote by Abraham Lincoln:");
System.out.println ("Whatever you are, be a good one.");
}
}
Slide 6
Now let’s look at the Java Program Structure example. You can see the different parts of the code
including the comments about each line of code.
// comments about the class
Slide 7
Java Program Structure
Slide 8
Comments
Comments in a program are called inline documentation
They should be included to explain the purpose of the program and describe processing steps
They do not affect how a program works
Java comments can take three forms:
Slide 9
Identifiers
Identifiers are the words a programmer uses in a program
An identifier can be made up of letters, digits, the underscore character ( _ ), and the dollar sign
Identifiers cannot begin with a digit
Java is case sensitive - Total, total, and TOTAL are different identifiers
By convention, programmers use different case styles for different types of identifiers, such as
title case for class names - Lincoln
upper case for constants - MAXIMUM
Slide 10
Reserved Words in Java
Some of the Java reserved words are as follows:
abstractelse
enum
extends
FALSE
final
finally
float
for
goto
if
implements
import
instanceof
int
assert
boolean
break
byte
case
catch
char
class
const
continue
default
do
double
interface
long
native
new
null
package
private
protected
public
return
short
static
strictfp
super
switch
synchronized
this
throw
throws
transient
TRUE
try
void
volatile
while
Slide 11
Spaces, blank lines, and tabs are called white space
White space is used to separate words and symbols in a program
Extra white space is ignored
A valid Java program can be formatted many ways
Programs should be formatted to enhance readability, using consistent indentation
Slide 12
Look at the Lincoln2.java example
public class Lincoln2{public static void main(String[]args){
System.out.println("A quote by Abraham Lincoln:");
System.out.println("Whatever you are, be a good one.");}}
Slide 13
Next let’s discuss Program Development
Slide 14
The mechanics of developing a program include several activities
writing the program in a specific programming language (such as Java)
translating the program into a form that the computer can execute
investigating and fixing various types of errors that can occur
Software tools can be used to help with all parts of this process
Slide 15
Each type of CPU executes only a particular machine language
A program must be translated into machine language before it can be executed
A compiler is a software tool which translates source code into a specific target language
Often, that target language is the machine language for a particular CPU type
The Java approach is somewhat different
Slide 16
The Java compiler translates Java source code into a special representation called bytecode
Java bytecode is not the machine language for any traditional CPU
Another software tool, called an interpreter, translates bytecode into machine language and executes it
Therefore the Java compiler is not tied to any particular machine
Java is considered to be architecture-neutral
Slide 17
The structure of Java consists of Java source code, the Java compiler, Java bytecode, the bytecode
interpreter, the bytecode compiler and machine code
Slide 18
Farrell, J. (2014). Java Programming (7th ed.). Boston: Cengage Learning.
ISBN# 1-2850-8195-1 ISBN-13# 978-1-2582-9016-4
Yang, D. (2002, September 1). Retrieved , from
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=8&cad=rja&uact=8&ved=0CGsQ
FjAH&url=http%3A%2F%2Fcs.nyu.edu%2Fcourses%2Ffall03%2FV22.0101-002%2F01slide.ppt