BASIC JAVA
declaration statements
DIM n AS INTEGER
DIM message AS STRING
int n;
String message;
single precision numbers
DIM x AS SINGLE
float x;
increment statements
n = n + 1
n++;
n = n + 1; also works
count-controlled loops
FOR i = 1 to 10
	stuff to do
NEXT i
for (int i=0; i<10; i++){
	stuff to do;
}
condition-controlled loops
DO
	stuff to do
LOOP WHILE something is true
while (something is true){
	stuff to do;
}
*there is no "until" in Java
conditional statements
IF something is true THEN
	stuff to do
END IF
if (something is true){
	stuff to do;
}
*you never use "then" in Java
multiple case decision structure
SELECT CASE theVariable
CASE 1:
	do something
CASE 2:
	do something different
CASE ELSE:
	if all else fails do this
END SELECT
*theVariable could be any type
		
switch (theVariable){
case 1:
	do something;
	break;
case 2:
	do something different;
	break;
default:
	if all else fails do this
}
			
*theVariable must be an integer
*you can't give a range of values for a case
branching
EXIT DO
EXIT FOR
EXIT SUB
			
break;

return; (to leave a subroutine)
			
equality comparison operator
IF numGuesses = 10 THEN
*equality comparison operator is same as assignment operator
if (numGuesses = = 10){
*conditional uses = = for the equality sign
"and" operator for boolean expressions
IF numGuesses = 10 AND playerScore < 5 THEN
if (numGuesses = = 10 && playerScore < 5){
*make sure you use both of those ampersands
"or" operator for boolean expressions
IF numGuesses = 10 OR playerScore < 5 THEN
if (numGuesses = = 10 || playerScore < 5){
*that | symbol is right next to the curly bracket key. Make sure you use two of them.
arrays
DIM arrayName(1 TO 5) AS INTEGER
arrayName(1)=8
			
//create an array of five integers
int[] arrayName = new int[5];
//assign the first integer a value of 8
arrayName[0]=8;
or
//create an array of five Locations
Location[] vertex = new Location[5];
//use the class constructor to create each individual Location
vertex[0]=new Location();
vertex[1]=new Location();
*arrays in Java are always zero-based;
*you need to create the array to hold the objects and you need to create each individual object itself, typically with the class constructor.
user-defined types
TYPE Player
	score AS INTEGER
END TYPE
			
public class Player{
	int score;
}
			
creating subroutines
SUB sayHello
	PRINT "Hello"
END SUB
			
public void sayHello(){
	System.out.println("Hello");
}
			
creating subroutines that return something
FUNCTION computeAverage(a AS SINGLE, b AS SINGLE)
	DIM average AS SINGLE
	average = (a + b)/2;
	'return statement
	computeAverage=average;
END FUNCTIOn
			
public float computeAverage(float a, float b){
	float average=(a+b)/2;
	'return statement (uses the word return--isn't that nice?)
	return average;
}
			
calling subroutines (no return value)
sayHello
			
sayHello();
			
calling subroutines (with a return value)
myCurrentAverage = computeAverage(testGrade1, testGrade2)
			
myCurrentAverage = computeAverage(testGrade1, testGrade2);
			
named constants
CONST up = 1
			
public static final UP = 1;
			
modulus operator
n MOD 5
			
n % 5
			
integer ranges integers range from -32767 to 32767
long integers range from -2^31 to 2^31
integers in java are like longs in qb (-2^31 to 2^31)
longs are really long! (-2^63 to 2^63)