Chapter 1 Helper Sheet

Java Template for introductory projects - just know how to use it when you have it for reference:

public class classname{

public static void main(String[] args) {

the program work is all in here
}

}

Types:

Create a variable:

type name ; OR type name = value; // (For String use " ", for char use ' ')

ex: int x = 1;

Change a variable:

variable = something; // something can be another variable or math using * / + -

ex: x = y * 2 / 3 + a;

Print to the screen:

System.out.println ( what you want to output ); // inside parentheses put "string" and variables separated with +

ex: System.out.println ("The average is" + avg + "\n The product is:" + product);

Play with strings:

ex: newString = myOriginalString.toLowerCase();

Also, strings can be put together into another string with the +

ex: newString = string1 + string2;

Variable name (Identifier) rules:

Comments: