Lecture 2 - Basic Concepts in Java
Lecture 2 - Basic Concepts in Java
Java
Java Comments
Comments
• The purpose of including comments in your
code is to explain what the code is doing.
• Java supports both single and multi-line
comments. All characters that appear within a
comment are ignored by the Java compiler.
• A single-line comment starts with two
forward slashes and continues until it
reaches the end of the line.
Example
Multi-Line Comments
Java also supports comments that span multiple
lines.
Example
Documentation
Comments
Documentation comments are special
comments that have the appearance of
multi-line comments, with the difference
being that they generate external
documentation of your source code.
Example
Variables
Variables store data for processing
A variable is given a name (or identifier),
such as area, age, height, and etc. The
name uniquely identifies each variable,
assigning a value to the variable and
retrieving the value stored.
There are many data types for variables,
some examples are
System.out.println(myVar.nextLine());
}
}
END