“We are about to study the idea of a computational process. Computational processes are abstract beings that inhabit computers. As they evolve, processes manipulate other abstract things called data. The evolution of a process is directed by a pattern of rules called a program. People create programs to direct processes. In effect, we conjure the spirits of the computer with our spells.

A computational process is indeed much like a sorcerer’s idea of a spirit. It cannot be seen or touched. It is not composed of matter at all. However, it is very real. It can perform intellectual work. It can answer questions. It can affect the world by disbursing money at a bank or by controlling a robot arm in a factory. The programs we use to conjure processes are like a sorcerer’s spells. They are carefully composed from symbolic expressions in arcane and esoteric programming languages that prescribe the tasks we want our processes to perform.

A computational process, in a correctly working computer, executes programs precisely and accurately. Thus, like the sorcerer’s apprentice, novice programmers must learn to understand and to anticipate the consequences of their conjuring. Even small errors (usually called bugs or glitches) in programs can have complex and unanticipated consequences.”

― Harold Abelson, Structure and Interpretation of Computer Programs

Java main method

To run our program, the main method must be identical to this signature

public static void main(String[ ] args)

  • Public : anyone can see it
  • Statuc : method can be run without creating an instance of the class containing the main method 
  • Void : method doesn’t return any value 
  • Main : name of the method
  • Main’s parameters are is an array of strings called  args 

Methods

A method is a collection of statements grouped together for an operation
Aka functions 

Java syntax

  • ​In classes, methods, and other flow-control structures code is always enclosed in curly braces { }.
  • Each code statement must end with a semicolon


Comments


  • single-line comments  start with two forwars slashes //
  • multi-line comments start with forwars slash followed by asterisk /*  and end vice versa */ 

/*  This is also a

    comment spanning

    multiple lines */

Documentation comments

  • generate external documentation of your source code
  • These begin with a forward slash followed by two asterisks, and end with an asterisk followed by a forward slash.

/** This is a documentation comment */
/** This is also a

    documentation comment */

Javadoc is a tool which comes with JDK and it is used for generating Java code documentation in HTML format from Java source code which has required documentation in a predefined format.
When a documentation comment begins with more than two asterisks, Javadoc assumes that you want to create a “box” around the comment in the source code. It simply ignores the extra asterisks.

/**********************
This is the start of a method
***********************/

Variables

Variables store data for processing.

A variable is given a name (or identifier), such as area, age, height, and the like. The name uniquely identifies each variable, assigning a value to the variable and retrieving the value stored.
Variables have types. Some examples:

int: for integers (whole numbers) such as 123 and -456

double: for floating-point or real numbers with optional decimal points and fractional parts in fixed or scientific notations, such as 3.1416, -55.66.

String: for texts such as “Hello” or “Good Morning!”. Text strings are enclosed within double quotes.
You can declare a variable of a type and assign it a value. Example:

String name = “Jason”;

This creates a variable called name of type String, and assigns it the value “Jason”.

You can use a comma-separated list to declare more than one variable of the specified type. Example: 

int a = 42, b = 11;

println method

  • println method prints a line of text 
  • The  System class and its out stream are used to access the println method 

    {
    System.out.println(“Hello World!”);
    }