Java checks the type of each variable before your program runs. A declaration names the type and the variable; an assignment gives it a value. The eight primitive types are byte, short, int, long, float, double, char and boolean. String is a reference type for text. Use int for ordinary whole counts, long when a count can exceed the int range, and double when a fraction matters.
Your workspace supplies program startup and test input. You write a public method inside class Solution, so you can focus on one computation instead of reading the console. Braces mark blocks and semicolons end statements. Return sends a value back to the caller. Printing a message only writes debugging output.