• Comments
  1. Single line – //
  2. Multi-line – /* … */ – must contain a public class called Main

*Every Java file contains exactly one public class. This class has the same name as the name of the file

Class – file name extension of bitecode files; independent part of the program

*All class names and Java file names should start with a capital letter

Package – software library that contains several programs that are packaged together; broken down into classes; starts with lowercase

Classes – contain methods and variables

Main Method – required in every Java app; where the program starts executing

public static void main(String[] args) – variable args is the array of strings that is passed as input to the program

* It is possible to have multiple main methods, however, you need to explicitly specify which main method should be the starting point of the program


  • Print

System.out.print – print without moving to the next line

System.out.println – print and then print new line

\ – displays a special character

\n – displays a new line “Hello\n World\n”

Ctrl+Space – autocomplete

*Spacing and new lines are not always important

  • Read

Scanner keyboard = new Scanner reads input

  • Operations

Arithmetic Operators: +, -, *, / and %

Modulus Operation or % – remainder

Relational / Comparison Operators: ==, <, <=, >, >=, !=;

Operations with the same precedence are performed left to right

Equality operators – ==, !=; used to test equality; do not require that operands share the same ordering


*compareTo method returns a positive integer when the first string is bigger,
0 when the two strings are the same, and a negative integer when the first string is smaller

  • Switch Statementsupports only on variables of type int, char, and string; does not support on doubles

Algorithm Scripting: code

About bernadetteengleman

Hello, I am Bernadette from New York City. I moved here from Chicago in 2013. I am originally from the Philippines. I started studying web programming in 2015. I love it because I like making fun websites and web apps. The projects that I built so far are posted below. I like to cook and I love to travel. I also like to volunteer and I am a team leader with the non-profit organization, NYCares.
This entry was posted in Java and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s