Save
Dcit23
lesson 2
Save
Share
Learn
Content
Leaderboard
Learn
Created by
PoliteMongoose93816
Visit profile
Cards (34)
Data Type
A classification system in Java used to specify the
variables'
value
type
View source
The data type used varies on what kind of operation it needs to be used upon
without
any
errors
View source
Primitive Data Types
Data types that are built into a programming language, also called
pre-defined
data types
View source
Non-Primitive
Data Types
Data types that are not built into the programming
language
View source
Primitive
Data Types
Integers
,
floating points
, characters are some examples
Can be used by the user to declare
variables
directly
View source
Integer
Represents whole
numbers
, ranges from -2147483648 to
2147483647
, uses 4 bytes of memory
View source
Integer
int Age =
21
;
View source
Character
Used for
storing
characters, uses
1
byte of memory, enclosed in single quotes
View source
Character
char MiddleInitial =
'A'
;
View source
Boolean
True or False values, uses
1
byte, usually used for
conditional operations
and looping
View source
Boolean
bool is_
true
=
true
;
View source
Floating-Point
Used for holding
floating-point
numbers (decimals and exponents), uses 4 bytes, stores
6-7
decimal points
View source
Floating-Point
float Pi =
3.14
;
View source
Long
Stores whole numbers from
-9
,
223
,372,036,854,775,808 to 9,223,372,036,854,775,807
View source
Long
long num1 =
254512131215848
;
View source
Short
Stores whole numbers from
-32,768
to
32,767
View source
Short
Short num2 =
30000
;
View source
Double Float
Same as
float
but has double precision on
decimal
values, stores 15 decimal digits
View source
Double Float
double Pi =
3.1415
;
View source
Void
Represents a
valueless
entity, used for
functions
that do not return a value
View source
Void
void
FunctionName
(){}
View source
Array
A collection of items stored at
continuous
memory locations
View source
String
Designed to hold a sequence of
characters
in a single
variable
View source
Operators
Symbols used to indicate an operation that tells what to do with the
numbers
in order to get to the
final
result
View source
Types of Operators
Arithmetic
Operators
Relational
/
Comparison
Operators
Logical
Operators
View source
Arithmetic Operators
Addition (
+
), Subtraction (
-
), Multiplication (*), Division (/), Modulus (%), Increment (++), Decrement (--)
View source
Relational
Operators
Equal
to (==), Not Equal to (!=), Greater than (>), Less than (<), Greater than or
Equal
to (>=), Less than or Equal to (<=)
View source
Logical
Operators
Logical
and (&&),
Logical
or (||), Logical not (!)
View source
Implicit
Conversion
Java
automatically
converts between certain
data types
if they are compatible
View source
Implicit Conversion
int
a =
10
;
long b = a; //this converts the value of a from
int
to
long
View source
Casting
You can use casting to convert between certain data types that are not
automatically compatible
View source
Casting
double num =
1.2
;
int numm = (
int
) num; //convert the value of num from double to
int
View source
String Parsing
You can convert a String to another data type using
parsing
methods
View source
String Parsing
String
thisString
= "
5
";
int thisInt = Integer.parseInt(thisString); //
converting
from
string
to int
View source