Java PowerPoint PPT Presentation

presentation player overlay
About This Presentation
Transcript and Presenter's Notes

Title: Java


1
Java
  • Words, Symbols and Rules

2
Java Program Structure
  • JAVA program
  • A program is made up of one or more classes.
  • The inside name of the class should always
    match the outside name of the class.
  • A class contains one or more methods
  • You need to have a main method. Java looks
    for it in order to begin execution.
  • A method contains program statements
  • Such as System.out.println(Some
    String)

3
Program Statements
  • Almost every statement ends in a semi-colon.
    There are very few exceptions.
  • Be careful with statement indentation
  • You will increase indentation after an opening
    bracket
  • You will decrease indentation after a closing
    bracket

4
Elements of Programming
  • We need to reserve memory in order to store the
    different values that will be used by our program
    to perform calculations.

5
Variable Declaration and Initialization
  • Declaring a variable
  • Initializing a variable
  • Declaring and initializing

JAVA is strongly typed
int x
x 5
int x 5
6
Variable declaration and comments
  • One variable declaration per line please
  • After the declaration/initialization you should
    describe what the variable does.

int age, yearsOfMarriage, numberOfChildren int
age 25 //the persons age
7
In Memory
int x 5
5
X
8
Overwrite
int x 5
x 3
9
Identifiers
  • Identifiers/Variable names 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

10
Primitive Data types
  • int
  • double
  • char
  • boolean

11
Reserved Words
  • A reserved word cannot be used in any other way
  • The Java reserved words

abstract assert boolean break byte case catch char
class const continue default do double
else enum extends false final finally float for go
to if implements import instanceof int
interface long native new null package private pro
tected public return short static strictfp super
switch synchronized this throw throws transient tr
ue try void volatile while
12
Primitive Data Types
Identifiers
Reserved Words
Write a Comment
User Comments (0)
About PowerShow.com