0% found this document useful (0 votes)
31 views

01 - Java Review v2

This document summarizes key concepts in Java including primitive data types, variables, strings, comments, mathematical and logical operators, assignment operators, and loops. It outlines the different primitive data types in Java including byte, short, int, long, float, double, boolean, and char. It also discusses variables, strings, comments (single-line, multi-line, and Javadoc), unary, mathematical, relational, equality, logical, and assignment operators. Finally, it provides examples of for, while, and do-while loops in Java.

Uploaded by

chuckiekills
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

01 - Java Review v2

This document summarizes key concepts in Java including primitive data types, variables, strings, comments, mathematical and logical operators, assignment operators, and loops. It outlines the different primitive data types in Java including byte, short, int, long, float, double, boolean, and char. It also discusses variables, strings, comments (single-line, multi-line, and Javadoc), unary, mathematical, relational, equality, logical, and assignment operators. Finally, it provides examples of for, while, and do-while loops in Java.

Uploaded by

chuckiekills
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Java Review


DASTRAP Term 2, SY 2009 -
2010
Variables
• Primitive Data types
▫ byte -128 -> 127
▫ short -32,768 -> -32,767
▫ int -2,147,483,648 -> 2,147,483,647
▫ long -9,223,372,036,854,775,808 ->
9,223,372,036,854,775,807
▫ float single-precision 32-bit IEEE 754 floating
point
▫ double double-precision 64-bit IEEE 754 floating
point
▫ boolean true or false
▫ char ex. ‘a’
Variables
• String – not a primitive data type! But java has
special support

• String literals are enclosed in “ ”


• Can be concatenated
Comments
• Single line //
• Multiple line /*
*/
• Javadoc /**
*/
Unary
!
++
--
Mathematical Operations
*
/
%
+
-
Relational
>
<
>=
<=
Equality
==
!=
Logical AND, OR
&&
||
Assignment
=
+= ++ equal to +=1 x = 1; x+=3; //x=4
-= -- equal to -=1 x = 3; x-=1; //x=2
*= x = 2; x*=4; //x=8
/= x = 9; x/=3; //x=3
%= x = 9; x%=2; //1
Loops

for
● while
● do-while
Loops
for( int i=0; i<5 ; i++)
{
print(“.”);
}
Result:
.....
Loops
int i=0;
while(i<5)
{
print(“.”);
i++;
}
Result:
.....
Loops
int i=0;
do{
print(“.”);
i++;
}
while(i<5);
Result:
.....

You might also like