Java Tokens: Tokens are the ones which are used to prepare a program. The statements of a java program contain expressions, which describe the actions carried out on data. Smallest individual units in a program are known as tokens. The compiler recognizes them for building up expressions and statements.
In simple terms, a Java program is a collection of tokens, comments and white spaces. Java language includes five types of tokens. They are:
1. Reserved Keywords
2. Identifiers
3. Literals
4. Operators
5. Separators
Java Character Set: The smallest units of Java language are the characters used to write Java tokens. These characters are defined by the Unicode character set. The Unicode is a 16-bit character coding system and currently supports more than 34,000 defined characters derived from 24 languages.
Keywords: Keywords are an essential part of a language definition. They implement specific features of the language. Java language has reserved 50 words as keywords. Since keywords have specific meaning in Java, we cannot use them as names for variables, classes, methods and so on. All keywords are to be written in lower-case letters.
Identifiers: Identifiers are user defined tokens. They are used for naming classes, methods, variables, objects, labels, packages and interfaces in a program. Java identifiers follow the following rules:
1. They can have alphabets, digits, and the underscore and dollar sign characters.
2. They must not begin with a digit.
3. Uppercase and lowercase letters are distinct.
4. They can be of any length.
Literals: Literals in Java are a sequence of characters (digits, letters, and other characters) that represent constant values to be stored in variables. Java language specifies five major types of literals. They are:
1. Integer literals
2. Floating point literals
3. Character literals
4. String literals
5. Boolean literals
Operators: An operator is a symbol that takes one or more arguments and operates on them to produce a result. Operators are of many types such as arithmetic, relational and etc.
Separators: Separators are symbols used to indicate where groups of code are divided and arranged. They basically define the shape and function of our code. They include symbols like braces, comma and etc.
0 comments:
Post a Comment