Learning Java - 01

This is a summary of what I learnt in Chapter One of Core Java for the Impatient.

They are also pointers for topics to research more about as you try to learn Java.

Comments

There are three types of code comments in Java:

  1. Single line comments
  // Every thing from here till the end of this line is ignored by the compiler.
  1. Multi line comments
  /*
    Once you start writing multiple single line comments it would be best to switch to multi line because they reduce
    repetition.
  */
  1. Documentation comments
  /**
    Once comments become manuals rather than notes to your future self, this is your best buddy.
  */

Compilation

Java is a compiled language, which implies that there is a compilation process. It is a multi-stage process that involves:

  1. Converting the source code stored in .java files into bytecode (a platform independent intermediate language format that can be run anywhere there’s a Java Virtual Machine) using a command like this:
javac path/to/srcFile.java

The generated bytecode is stored in .class files.

  1. The bytecode is then run in the Java Virtual Machine (a piece of software that can convert bytecode into platform specific machine code) using the command:
java path/to/byteFile  # Notice that there are no extensions at the end of the path.

If you have a JDK installed and you just want to play around with some Java, run the command jshell on your terminal. It opens a REPL interface that encourages quick hacking.

Types

Variables

Casting and Conversion

Arithemetic Operators

Standard I/0

Control flow

Arrays and ArrayLists

Methods