Primitive types: (don't have to create an object to store it)
byte : 8-bit integer => -128~127
short:16-bit integer => -32,768~32,767
int : 32-bit integer => -2,147,483,648 ~ 2,147483647
long : 64-bit
float : 32-bit
double: a 64-bit floating-point number
boolean: "true" or "false" ("True" or "False" in Python)
char: a character, 2byte, non-signed
e.g.
long x = 43L;
double & float values must have a decimal point:
double x = 10.0;
float x = 43.9f;
Object types Primitive types
-------------------------------------------------------------------------------------------
Contains a reference value
How defined? class definition built into Java
How created? "new" "6", "3.4", "true", etc.
How initialized? constructor default (usually zero)
How used? method operators("+", "*",...)
Function: methods declared to return a non-void type.
char c = new char[4];
c[4] = 'x'; //Run-Time error
The size of an array cannot be changed once it has been created.
No comments:
Post a Comment