Open Source Projects
In this tutorial we will learn about Java tokens.
It is a set of characters that we use to write Java code.
Java uses Unicode character set that supports 34,000+ characters from 20+ languages.
Token is the smallest individual unit of a program.
Following are the tokens used in Java programming language.
Keywords are the words that conveys a special meaning to the language compiler and are reserved for special purpose and hence must not be used as normal identifier name.
Following are the keywords used in Java.
Identifiers are used as the general terminology for the names givens to different parts of the program like the name of the variables, methods, arrays etc.
Identifiers name are user-defined and must follow the given rules.
Example: age, _score, isGameOver etc.
Literals are the sequence of characters using digits, letters and other symbols, to represent values that is stored in variables.
There are five types of literals in Java.
Integers are numbers without decimal parts and there are three types of integers namely decimal, octal and hexadecimal integers.
Decimal integers are in base 10 number system and uses 10 digits from 0 to 9.
Example: -9, 0, 10 etc.
Octal integers are in base 8 number system and uses 8 digits from 0 to 7 with a leading 0.
Example: 07, 017 etc.
Hexadecimal integers are in base 16 number system and uses 10 digits from 0 to 9 and 6 letters from A to F with leading 0x and 0X. Lowercase letters from a to f can also be used.
Example: 0x11, 0xAA, 0xbb, 0x12F etc.
Click here for tutorial series on conversion of numbers from decimal to binary, octal, hexadecimal number system.
These are the numbers having decimal part. Example -10.2, 0, 100.99 etc.
A character literal is a symbol enclosed in single quotes.
Example: 'a', '1' etc.
A string literal is a sequence of characters enclosed in double quotes.
Example: "Hello World"
Boolean literal are either TRUE or FALSE.
An operator is a symbol that takes one or more arguments and then performs some operations and returns some result.
Example: The addition operator + takes two numbers and returns the sum.
Separators are symbols that we use to group or arrange our code.
Example: We use the parenthesis () to enclose parameters of a method. We also use them to group variables and values in an expression like (10 + a) - b where, a and b are some variables.
(10 + a) - b
We use comments to describe the code, highlight points that can be referred by the developer and to prevent a piece of code from getting compiled.
There are two type of comments in Java similar to other programming languages like Java, Php, C++ etc.
We use the two forward slash to create single line comments.
// this is a single line comment
We use the /* to start a multi line comment and */ to end a multi line comment.
* this is a
* multi line comment
Have fun learning :-)
Copyright © 2014 - 2018 DYclassroom. All rights reserved.
rendered in 0.0570 sec