Java Notes
Java Notes
Comments
The comment statement is a non-executable statement in
Java. It included for the user to understand what action is
going to be taken in a program or a statement.
Tokens
All characters in a java program are grouped into symbols
called Tokens. A computer program is a set of instructions
called statements.A statement is composed of various
components.Each individual component of a programming
statement is referred to as tokens.
There are five categories of token in Java.These are:
1. Keywords
2. Identifiers
3. Literals
4. Punctuators
5. Operators
Keywords
Keywords,also known as Reserved Words,are the words
that have a special meaning to the Java compiler. Java
compiler reserves these keywords for its own use and
hence they are not available as names for variables or
methods.
Identifiers
Identifiers are used to name different components of a program
such as variables, methods, objects etc.
Examples:
int age = 25; // Integer literal
double pi = 3.14159; // Floating-point literal
char grade = 'A'; // Character literal
String name = "Alice"; // String literal
boolean isJavaFun = true; // Boolean literal
Keywords
Reserved words with special meaning in Java.
Examples: class, public, static, if, else, return, int, void
Identifiers
Names given to variables, methods, classes, etc.
Must start with a letter, underscore (_), or dollar sign ($);
followed by letters, digits, underscores, or dollar signs.
Examples: myVariable, Main, _count, $value
Literals
Constant values directly used in code.
Examples: 100, 3.14, 'A', "Java", true, null
Operators
Symbols that perform operations on variables and values.
Examples: +, -, *, /, =, ==, !=, ++, &&, ||
Separators (Delimiters)
Symbols used to separate code elements.
Examples:
; (statement terminator)
, (separator)
. (member access)
() (method call or grouping)
{} (block of code)
[] (array declaration/access)