Given a string str
you can print to the console using System.out.println
or System.out.print
You can create an integer variable with the keyword int
like so
Methods can take in values, called parameters.
The method below takes in a parameter called input
and prints it.
Methods can also return a value.
The method below takes in a value, adds two to it, and returns it.
You can collect user input in programs with a Scanner
Initializing a Scanner
Read a string
Read an integer
Read a double
Read a boolean
Comparison operators return booleans (true/false values)
Comparison operators in if statements
Operators
Examples
Increment (add one)
Decrement (subtract one)
Shortcuts