Introduction%20to%20Java%20Programming - PowerPoint PPT Presentation

View by Category
About This Presentation
Title:

Introduction%20to%20Java%20Programming

Description:

root1. isLeapYear. Quadratic. LeapYear. MAX. variable names ... double root1, root2; Initializing variables. int x = 5; int y; //y need not be initialized ... – PowerPoint PPT presentation

Number of Views:10
Avg rating:3.0/5.0
Slides: 26
Provided by: csp19
Learn more at: http://www.cs.pitt.edu
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Introduction%20to%20Java%20Programming


1
Lecture 2
  • Introduction to Java Programming

2
(No Transcript)
3
(No Transcript)
4
(No Transcript)
5
Java Class Format
public class userDefinedName public static
void main(String args)
6
(No Transcript)
7
2.2 Primitive Data Types
8
(No Transcript)
9
(No Transcript)
10
(No Transcript)
11
(No Transcript)
12
(No Transcript)
13
(No Transcript)
14
(No Transcript)
15
(No Transcript)
16
Lexical Elements
  • Keywords
  • Literals
  • Identifiers
  • Operators
  • Punctuation

17
Keywords
abstract default if private this boolean
do implements protected throw break
double import public throws byte else
instanceof return transient case extends
int short try catch final interface
static void char finally long strictfp
volatile class float native super while
const for new switch continue goto
package synchronized
  • Can not be used for any other purpose
  • All lowercase letters

18
Literal
  • A literal is the source code representation of a
    value of a primitive type or the String type

Data type Literal Examples int -4501
double 35.271d char b
boolean true String Hello World
19
Identifiers
  • An identifier is an unlimited-length sequence of
    Java letters and Java digits, the first of which
    must be a Java letter. An identifier cannot have
    the same spelling as a keyword or boolean literal.

Example identifiers sum prod root1 isLeapYear
Quadratic LeapYear MAX
20
Operators
21
Punctuation
  • The following nine ASCII characters are the
    separators (punctuators) ( )
    , .

22
White Space
  • White space is defined as the ASCII space,
    horizontal tab, and form feed characters, as well
    as line terminators

23
Comments
  • There are two kinds of comments
  • / text / A traditional comment all the text
    from the ASCII characters / to the ASCII
    characters / is ignored by the compiler
  • // text A end-of-line comment all the text from
    the ASCII characters // to the end of the line is
    ignored by the compiler.

24
All variables must be defined
  • Tell the compiler the
  • name of each variable
  • type of each variable

int x int y boolean isLeapYear boolean
isPerflick double root1 double root2
int x, y boolean isLeapYear, isPerflick double
root1, root2
25
Initializing variables
int x 5 int y //y need not be
initialized y 2x 1
About PowerShow.com