Download presentation

Presentation is loading. Please wait.

Published byAlden Burnison Modified over 2 years ago

2
Base “primitive” types:

3
TypeDescriptionSize intThe integer type, with range -2,147,483,648... 2,147,483,647 4 bytes byteThe type describing a single byte, with range -128... 127 1 byte shortThe short integer type, with range -32768... 32767 2 bytes long The long integer type, with range -9,223,372,036,854,775,808... -9,223,372,036,854,775,807 8 bytes doub le The double-precision floating-point type, with a range of about ±10 308 and about 15 significant decimal digits 8 bytes Primitive Types float The single-precision floating-point type, with a range of about ±10 38 and about 7 significant decimal digits 4 bytes char The character type, representing code units in the Unicode encoding scheme 2 bytes bool ean The type with the two truth values false and true1 bit

4
Constants

5
Create Examples 1.Create a constant for number of inches in an foot (FOOT_VALUE) 2.Create a constant for number of feet in a yard (YARD_VALUE). 3.Write code to find out how many yards given n feet. Constants: final

6
Precedence OperatorDescription Higher ( )Parentheses +Positive - Negative * Multiplication / Division % Modulus (remainder) +Addition Lower - Subtraction =

7
Sample Arithmetic Expressions: 2 2 * 3 2 + 4 * 3 - 7 4 / 2 10 % 3 (2 + 3) * (11 / 12)

8
May mix types Two variables only at a time! Mod (%) operator:

10
We can also do this using shorthand = a += 5; a = a + 5; a -= 5; a = a - 5; a *= 5; a = a * 5; a /= 5; a = a / 5; a %= 5; a = a % 5; a++; a = a + 1; a--; a = a - 1;

11
Variable increment operators: i++ ++I

13
A String: String constants String variables: String length: Empty string Strings

14
String sub = greeting.substring(0, 5); // sub is "Hello“ Substrings

16
Dialog Boxes

17
static String showInputDialog (object msg) number = JOptionPane.showInputDialog (“Enter a number: “); Enter an Integer: ? OK Cancel 24 Input

18
static int showConfirmDialog (component parent, object msg) ans = JOptionPane.ConfirmDialog (“Try Again? “); Try Again? ? NoCancel Select an Option Yes

19
static void showMessageDialog (component parent,object msg) JOptionPane.showMessageDialog (“The Number is an Integer “); The Number is an Integer i OK Message

20
parseInt parseLong, parseFloat parseDouble

21
double _y1; int _y2; String _number; number = JOptionPane.showInputDialog (“Enter a number: “); y1=Double.parseDouble(_number); y2= Integer.parseInt (_number);

22
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Math Class: sqrt pow round Plus others

Similar presentations

OK

Chapter 4 Fundamental Data Types. Chapter Goals To understand integer and floating-point numbers To recognize the limitations of the numeric types To.

Chapter 4 Fundamental Data Types. Chapter Goals To understand integer and floating-point numbers To recognize the limitations of the numeric types To.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on polynomials Ppt on soil pollution and its control Ppt on world environment day 2016 Ppt on web browser and web server Ppt on hydraulic power steering system Ppt on production function in short run Ppt on cell structure for class 8 Ppt on information technology in agriculture Ppt on national education day nepal Ppt on refraction of light through glass slab