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

Java Cheatsheet

The document provides an overview of common Java concepts such as import statements, data types, operators, loops, methods, classes, exceptions, and math functions. It lists Java packages, common file extensions, syntax for if/else statements, switch/case blocks, for, while, and do-while loops, and try/catch exception handling. The cheat sheet also includes examples of Java math functions from the Math class.

Uploaded by

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

Java Cheatsheet

The document provides an overview of common Java concepts such as import statements, data types, operators, loops, methods, classes, exceptions, and math functions. It lists Java packages, common file extensions, syntax for if/else statements, switch/case blocks, for, while, and do-while loops, and try/catch exception handling. The cheat sheet also includes examples of Java math functions from the Math class.

Uploaded by

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

JavaCheatSheet

JavaImportPackages ForLoop
i
mport<cl
ass>
f
or(
<ini
ti
alval
ue>;<condi
ti
on>;<i
n-/
decr
ement
>){
Packages <st
atement
(s)
>;
packagepackage_pat
h.package_name }

Common Extenti
ons
j
ava.
awt
,java.i
o,java.
lang,j
ava.
unt
il
l,j
ava.
swi
ng W hi
leLoop

DataTypes whi
l <condi
e( t
ion>){
<st
atement(s)
>;
bool
ean,char
,byt
e,shor
t,i
nt,f
loat
,long,doubl
e,St
ring
}

Comment s
//si
ngl
eli
necomment DoW hi
leLoop
/*mult
ili
necomment
do{
JavaOper
ator
s <stat
ement(s)
>;
}whi
l <condi
e( ti
on>) ;
+ Additi
on == Equal
- Subtraction !
= Notequal
* Multi
plicati
on < Lessthan Met
hod
/ Divi
sion <= Lessthanorequal
% Remai nder > Great
erthan <accessmodi
fier> <ret
urnt ype> <funct
ionname> (
<par
am>)
{
++ Incr
ement >= Great
erthanorequal
<declarat
ions>
— Decrement <statements>
[r
et ur
n;]
+= Addit
ionandassi gnment [r
et ur
n<expr ession>;]
-= Subtractionandassignment }
*= Multi
plicati
onandassignment
/= Divi
sionandassi gnment
%= Remai nderandassignment Cl
ass
! Not
|| Conditionalor <accessmodi
fi
er> <ret
urntype> <cl
assname> {
| Or <decl
arat
ions>
&& Conditionaland <methods>
}
& And
^ xor
?: Conditional Except
ion Handl
ing
+ Assi
gnment
t
ry{
IfElse <st
atement
s>
if(
<conditi
on>){ }
<st
atement(s)
>; catch(Excepti
one){
}else{ <stat
ements>
<st
atement(s)
>; }
} fi
nally{
<stat
ements>
Switch Case
swi
tch(<expression>)
{ JavaMat
h Cl
ass
case<opt i
on1>:
<st at
ement>; num abs(
num y); Absol
uteval
ueofy
break; num max(num y,num z); Maximum ofyandz
case<opt i
on2>: num min(num y,num z)
; Mini
mum ofyandz
<st at
ement>; doubl
e= Mat h.random(
); Random number
break;
default:
<st at
ement >;
break;
}

FreeJavaTutori
als@
www.JavaVi
deoCol
lecti
on.
com

You might also like