Here are the tools you need in your Java Toolbox in your head. The red words cannot be changed. The green can be changed by you:

public class MyClassName
{
     // you can define a class variable here
     public static void main( )
     {

           // your statements will go here
           // your calls to method1 will have the form: method1()
     }
     public static void method1( )
     {

           // your statements will go here
     }
}


You need to know how to use these for the midterm, but you do not need to memorize the commands. If you are asked to call these methods, you will be given the method name and parameters.


Creating methods:

public static return_type method_name (type parm1, type parm2)
{
...
...
return expression;
}

Calling methods:

object_or_class.method_name(parm1, parm2);


If / if else / else

if (condition that evaluates to true or false)
{
// do something
}
else if (condition that evaluates to true or false) // remember that everything that met first criteria doesn't get here
{
// do something else
}
.
. // repeat else if as needed
.
else // remember to put no condition
{
// do something
}

If facts:


Loops

For loop - repeats when you know the number of times to repeat


for (statement to start the loop; condition that evaluates to true or false; statement to run when the loop repeats)
{
// do something
}

For facts:

While loop - repeats until some condition is met


while (condition that evaluates to true or false)
{
// do something
// at some point, set the condition to stop
}