Show Menu
Cheatography

Software Java Cheat Sheet by

Data Types

byte
8 bits
short
16 bits
int
32 bits
long
64 bits
boolean
1 bit
char
16 bit unicode
float
32 bit decimal
double
64 bit decimal

Byte (8 bits/1 byte)

-128 to 127
-27 to 27 -1
Default value is : 0
Byte data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int

Short (16 bits/2 bytes)

-32,768 to 32,767
-215 to 215 -1
Short data type can also be used to save memory as byte data type. A short is 2 times smaller than an int

int (32 bits/4 bytes)

-231 to 231-1
default data type

Long (64 bits/8 bytes)

Default value is : 0L
long Variab­le_Name = Value_L;
 

Boolean (1 bits)

true and false
Default value is : false

Char (16 bits)

Unicode character
char a = 'A';
char japanese = "­\u....."

Double and Float

Decimal number
Double
64 bits/ 8 bytes
Float
32 bits / 4 bytes
mydouble = 0.1d
doublesci = 1.23e2 (scien­tific notation)
myfloat = 0.1f
 

Assign­ation Operator

Sign that use to determine data by using equal sign (=)
Ex. int x = 20;
x = 2 + 3 + 4;

Arithmetic Operator

a=30
b=15
+
Addition
a+b = 45
-
Subtra­ction
a-b = 15
*
Multip­lic­ation
a * b = 450
/
Division
a / b = 2
%
Modulus
a % b = 0
++
Increment
Increases the value of operand by 1 Ex. b++ = 16
--
Decrement
Decreases the value of operand by 1 Ex. b-- = 14

Relational Operator

==
equal to
!=
not equal to
>
grater than
<
less than
>=
grater than or equal to
<=
less than or equal to
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Selenium WebDriver Cheat Sheet Cheat Sheet
          Cypressio Cheat Sheet
          ISTQB Test Automation Engineering Cheat Sheet