Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Java Syntax Cheat Sheet, Cheat Sheet of Java Programming

Cheat sheet on Java Syntax: basic definitions, primitive data types, comments, elements, operators and separators.

Typology: Cheat Sheet

2019/2020

Uploaded on 10/09/2020

amodini
amodini 🇺🇸

4.7

(19)

258 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
BASIC DEFINITIONS
Class Describes a particular kind of object. It can
contain related methods and variables.
Method A function defined in a class. Methods
implement the behavior for objects.
Object The principal building blocks of Java.
Objects consist of variables (data) and
methods (functionality).
COMMENTS
HTML Comments
<!-- comment --> Sent to the client in the viewable
page source.
JSP Commens (Not Sent to Client)
<%-- comment
--%> Comments in JSP file.
// comment Comment in scriplet part of JSP
file.
ELEMENTS
Declaration
<%! declaration %> Creates a global
variable or method.
Expression
<%= expression %> Statements evaluated
on the server before
the page is outputted to
the client.
Page Directive
<%@ directive %> Attributes that apply to
the entire page.
Scriplet
<% code fragment of one or
more lines %> Contains a block of
scripting code which is
executed when the
page is generated.
Taglib Directive
<%@ taglib
uri="URIToTagLibrary"
prefix="tagPrefix" %>
Defines a tag library
and prefix for tags used
in a JSP page.
SEPARATORS
( ) Used to surround parameters
{ } Defines a block of code for a class or method or
to contain the values of automatically initialized
arrays
[ ] Declares arrays or references array values
; Denotes the end of a statement
, Separates variables
. Separates package names from subpackages/
classes or a variable/method from a reference
variable
PRIMITIVE DATA TYPES
Type Description Bits
(Integers)
byte Byte-length integer 8
short Short integer 16
int Integer 32
long Long integer 64
(Real Numbers)
float Single-precision floating point 32
double Double-precision floating point 64
(Other)
char A single character 16
boolean A boolean value (true or false) 1
OPERATORS
+ addition of numbers, concatenation of
Strings
+= add and assign numbers, concatenate
and assign Strings
- subtraction
-= subtract and assign
* multiplication
*= multiply and assign
/ division
/= divide and assign
% take remainder
%= take remainder and assign
++ increment by one
-- decrement by one
> greater than
>= greater than or equal to
< less than
<= less than or equal to
! boolean NOT
!= not equal to
&& boolean AND
|| boolean OR
== boolean equals
= assignment
JAVA SYNTAX CHEAT SHEET
Control
Flow
Selection
If
Else
Switch
Case
Loop
While
Do
For
Exception
Throw
Try
Catch
Finally
Branch
Return
Break
Continue
Label
Key
Words
abstract
assert
boolean
break
byte
case
catch
char
class
const
continue
default
do
double
else
enum
extends
false
final
finally
float
for
goto
if
implements
import
instanceof
int
interface
long
native
new
null
package
private
protected
public
return
short
static
strictfp
super
switch
synchronized
this
throw
throws
transient
true
try
void
volatile
while

Partial preview of the text

Download Java Syntax Cheat Sheet and more Cheat Sheet Java Programming in PDF only on Docsity!

BASIC DEFINITIONS

Class Describes a particular kind of object. It can contain related methods and variables. Method A function defined in a class. Methods implement the behavior for objects. Object The principal building blocks of Java. Objects consist of variables (data) and methods (functionality).

COMMENTS

HTML Comments

Sent to the client in the viewable page source. **JSP Commens (Not Sent to Client)** <%-- comment --%>

Comments in JSP file.

// comment Comment in scriplet part of JSP file.

ELEMENTS

Declaration <%! declaration %> Creates a global variable or method. Expression <%= expression %> Statements evaluated on the server before the page is outputted to the client. Page Directive <%@ directive %> Attributes that apply to the entire page. Scriplet <% code fragment of one or more lines %>

Contains a block of scripting code which is executed when the page is generated. Taglib Directive <%@ taglib uri="URIToTagLibrary" prefix="tagPrefix" %>

Defines a tag library and prefix for tags used in a JSP page.

SEPARATORS

( ) Used to surround parameters { } Defines a block of code for a class or method or to contain the values of automatically initialized arrays [ ] Declares arrays or references array values ; Denotes the end of a statement , Separates variables

. Separates package names from subpackages/ classes or a variable/method from a reference variable

PRIMITIVE DATA TYPES

Type Description Bits (Integers) byte Byte-length integer 8 short Short integer 16 int Integer 32 long Long integer 64 (Real Numbers) float Single-precision floating point 32 double Double-precision floating point 64 (Other) char A single character 16 boolean A boolean value (true or false) 1

OPERATORS

  • addition of numbers, concatenation of Strings += add and assign numbers, concatenate and assign Strings
  • subtraction -= subtract and assign
  • multiplication *= multiply and assign / division /= divide and assign % take remainder %= take remainder and assign ++ increment by one -- decrement by one

greater than = greater than or equal to < less than <= less than or equal to ! boolean NOT != not equal to && boolean AND || boolean OR == boolean equals = assignment

JAVA SYNTAX CHEAT SHEET

Control

Flow

Selection

If Else Switch Case

Loop

While Do For

Exception

Throw Try Catch Finally

Branch

Return Break Continue Label

Key

Words

abstract assert boolean break byte case catch char class const continue default do double else enum extends false final finally float for goto if implements import instanceof int interface long native new null package private protected public return short static strictfp super switch synchronized this throw throws transient true try void volatile while