0% found this document useful (0 votes)
2 views2 pages

Basic Java Cheat Sheet

This cheat sheet provides essential Java commands and concepts, including naming and number conventions, output window settings, color management, shape drawing, text handling, variable types, conditional statements, loops, and module creation. It emphasizes the use of Camel Case and Snake Case for naming, as well as the significance of the 8-bit architecture in number representation. Additionally, it outlines key functions and modules for programming in Java, particularly within the Processing environment.

Uploaded by

bobobobobbbbbbb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Basic Java Cheat Sheet

This cheat sheet provides essential Java commands and concepts, including naming and number conventions, output window settings, color management, shape drawing, text handling, variable types, conditional statements, loops, and module creation. It emphasizes the use of Camel Case and Snake Case for naming, as well as the significance of the 8-bit architecture in number representation. Additionally, it outlines key functions and modules for programming in Java, particularly within the Processing environment.

Uploaded by

bobobobobbbbbbb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Cheat Sheet

Basic Java Commands & Concepts

Naming Conventions
1. Names of programs start with a capital letter
2. Names of variables and functions are lower case letters
3. No spaces between words but each subsequent words begins with a capital letter is
called “Camel Case” or using underscores between words (older form or unix and MS
based) is “Snake Case.”

Number Conventions
Numbers start at 0 (for example first ten digits are 0,1,2,3,4,5,6,7,8,9)
Based on 8-Bit architecture of 2^8 (i.e 256 values) ranging from 0 to 255
0 is full off, 255 is full on, 63 is the first quarter, 127 is half and 191 is the three quarter value

Output Window
size( width, height );
background( colour ) ;

Colour
0 is Black, 255 is White, Everything in between is a Shade of Grey
Red, Green, Blue and Additive Light Colours (Cyan, Magenta, Yellow)
Opacity effects, append 0 (Transparent) to 255 (Opaque) to colour value or black/white value

Lines and Borders of Shapes


stroke( );
noStroke( );
strokeWeight();

Filling With Colour


fill( );
noFill( );

Shapes
point( x, y);
line( x1, y1, x2, y2);
rect( x, y, width, height);
note: x, y represent the top left corner of the rectangle
appending another value (or argument) rounds corners

ellipse(x, y, width, height);


note: x, y represent the centre of the ellipse

triangle( x1, y1, x2, y2, x3, y3);


quad( x1, y1, x2, y2, x3, y3, x4, y4);

Text
text( “Hello World”, x, y);
textSize( );

Variables
int x = 0; integers don’t have decimals
float y = 1.23; floats have decimals
boolean play = true; either True or False
char initial = “H”
String name = “Kevin”; strings of characters are words
Conditional Statements
if ( conditional ) equal to == and &&
{ not equal to != or ||
greater than >=
} less than <=

Loops
for( int i = 0; i < number of loops; i = i + 1 ); note: shorthand version of “i = i + 1”
{ is “i++”

Modules
Key Modules
void setup( ) void draw( )
{ {

} }

Common Modules
void keyPressed( ) void keyReleased( )
{ void mousePressed( )
int k = keyCode;
if ( k = = LEFT)
{

}
}

You can also create a module for anything else that you would like to use but you need to “call”
the module in your program (usually in the void draw).

References:
processing.org
coding-club.weebly.com

You might also like