Chapter 2: Programs, Data, Variables, and Calculations - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Chapter 2: Programs, Data, Variables, and Calculations

Description:

... Data, Variables, and Calculations. 2. Primitive Data Types ... All in Math class that is imported automatically in java.lang package. Examples: Math.sqrt ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 8
Provided by: far71
Category:

less

Transcript and Presenter's Notes

Title: Chapter 2: Programs, Data, Variables, and Calculations


1
Chapter 2 Programs, Data, Variables, and
Calculations
2
Primitive Data Types
  • Numerical
  • Byte (8 bits)
  • Short (16 bits)
  • Int (32 bits)
  • long (64 bits)
  • Float (32 bits)
  • Double (64 bits)

3
Arithmetic Operators
  • -
  • / (pay attention to integer division)
  • Example Fruit.java AverageFruit.java

4
Other Operators
  • , --
  • () casting
  • Op
  • Bitwise operators (, , , , gtgt, ltlt, gtgtgt)

5
Mathematical Functions
  • All in Math class that is imported automatically
    in java.lang package
  • Examples
  • Math.sqrt()
  • Math.sin()
  • Math.max()
  • Math.round()
  • Example MathCalc.java

6
Primitive Data Types
  • Characters
  • char (16 bits)
  • Escape characters (\b, \f, \n, \r, \t, \u)
  • String a series of character. Not a primitive
    data type, it is a class

7
Primitive Data Types
  • Logical
  • boolean (1 bit)
  • Two constants true and false
  • Comments // or / . /
Write a Comment
User Comments (0)
About PowerShow.com