JMU
Data Types and Variables
An Introduction with Examples in Java


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu


Data and Values
Variables and Constants
Variable/Constant Declarations
Some Atomic/Primitive/Fundamental Types in Java

Type Memory Range
byte 1 byte -128 to 127
short 2 bytes -32,768 to 32,767
int 4 bytes -2,147,483,648 to 2,147,483,647
long 8 bytes \(-2^{63}\) to \(2^{63}-1\)
float 4 bytes
double 8 bytes
char 2-4 bytes Unicode
boolean true or false

Non-Atomic Types in Java
Some Non-Atomic Types in Java
Names/Identifiers in Java
Names/Identifiers in Java (cont.)
Nerd Humor
http://imgs.xkcd.com/comics/x.png
(Courtesy of xkcd)
Java vs. Python - Important Differences
Declaration Statements in Java
Declaration Statements in Java (cont.)
Java vs. Python - Important Differences
Expressions Revisited