Loops ; Java

Loops are structures that are run repeatedly according to the instructions or conditions.
There are two types of loops in Java: a while loop and a for loop, both are written differently.

An example of a while-loop and a for-loop that prints 1 through 10

Conditions

A for-loop uses the syntax of for(int *var_name* = *value* ; *var_name with condition*; *change value of var_name*)
A while loop uses the syntax of while(*condition*) but the variable(s) must be created before the loop.



Syntax ; Writing

Here is the list:

public class Main{
*indent* public static void main(String[] args){
*indent* }
}



Comments & Inputs ; Writing

When writing comments, you use a double slash (//)
For inputs you need to import the scanner module as shown.



Writing Methods



Using ArrayLists and Arrays