SlideShare a Scribd company logo
Java Tokens: Keywords, Identifiers, Literals, Operators, and Seperators
A smallest individual unit in source code is known as Token
Java Tokens
Keywords Identifiers Literals Operators Seperators
Keywords are special tokens in the language which have reserved use in the language.
Keywords may not be used as identifiers in Java — you cannot declare a field whose name is a
keyword, for instance.
Java has 50 keywords among which 48 are in use but 2 (goto and const) are currently not in use
Here is a list of keywords in the Java programming language. You cannot use any of the
following as identifiers in your programs. The keywords const and goto are reserved, even
though they are not currently used. true, false, and null might seem like keywords, but they are
actually literals; you cannot use them as identifiers in your programs.
abstract continue for new switch
assert*** default goto* package synchronized
boolean do if private this
break double implements protected throw
byte else import public throws
case enum**** instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp** volatile
const* float native super while
* not used
** added in
1.2
*** added in
1.4
**** added in
5.0
Identifiers are the names of variables, methods, classes, packages and interfaces.
• Don’t use a keyword
• Don’t use a space
• Don’t use a special symbol other than ( _ and $ )
• Cannot start with digit
• Any length
• If only a single word then use a lowercase
• If more than one word then start first word with lowercase and other words start with first
letter as Capital
For example:
int balance=500; //Single word
int bankBalance=500; //Multiple Words
• Use lowercase
For example:
package pack1;
package mypack1;
• Every word start with first letter as Capital
For example:
class Balance{}
class BankBalance{}
• Use Uppercase and Underscore for separating the words
For example:
int PI=3.14;
int MAX_VALUE=100;
Fixed value assigned to variables or used in expressions is known as Literals
• Integer Literals: for example: 1, -2, 8523, -2105 etc.
Data Type Size Range
byte 1 Byte -27 to 27 -1
short 2 Bytes -215 to 215 -1
int 4 Bytes -231 to 231 -1
long 8 Bytes -263 to 263 -1
• Floating Literals: for example: 1.02, -2.689, 8523.369, 2105 etc.
Data Type Size Range
float 4 Byte -3.4 * 1038 to 3.4 * 1038
double 8 Bytes -1.7 * 10308 to 1.7 * 10308
• Character Literals: for example: ‘A’, ‘B’, ‘@’, ‘&’ etc.
Data Type Size Range
char 2 Bytes All Unicode characters
• String Literals: for example: “Hello”, “Gurpreet Singh”, “ACET” etc.
Data Type Size Range
String 2 * No. of characters As much memory available
• Boolean Literals: true and false.
Data Type Size Range
boolean 1 Byte true or false
• Null Literals: null can be assigned to any reference type
Operators operates on operands. For example: In expression a+b , a & b are operands and +
is operator
• Arithmetic Operator: +, - , *, /, %. For example:
5+4 will result in 9 5-4 will result in 1 5*4 will result in 20 5/4 will result in 1
5%4 will result in 1 (remainder) -5%4 will result in -1 5%-4 will result in 1 -5%-4 will result in -1
Note: Sign of result in % operator depends on the sign of dividend(numerator)
• Relational Operator: <, >, <=, >=, ==, != Output will be either true or false
5>6 will result in false
5>=6 will result in false (either greater than or equal to)
5<6 will result in true
5<=6 will result in true (either less than or equal to)
5==6 will result in false (equal to)
5!=6 will result in true (not equal to)
• Assignment Operator: = Assign the value on left hand side to right hand side. For example:
A=10+5, will assign 15 to A
• Logical Operator: returns true or false
Logical AND (&&)
Logical OR (||)
Logical NOT (!)
A B A&&B A||B !A
true true true true false
true false false true false
false true false true true
false false false false true
• Increment/Decrement Operator: increases or decreases the value by 1
Pre-increment & Pre-decrement: ++a, --a
Post-increment & Post-decrement: a++, a--
• Bitwise Operator: Performs operations on bits
Bitwise AND(&)
Bitwise OR(|)
Bitwise XOR(^)
Bitwise Complement or Not (!)
A B A&B A|B A^B !A
0 0 0 0 1 1
0 1 0 1 0 1
1 0 0 1 0 0
1 1 1 1 1 0
• Shift Operator: shift the bits to left or right
Left Shift(<<): shifts the bits to left and fill the vacant spaces with 0
Unsigned Right Shift(>>>): shifts the bits to right and fill the vacant spaces with 0
Signed Right Shift(>>): shifts the bits to right and fill the vacant spaces with leftmost bit, i.e. if
leftmost bit is 0 then fill with 0, and if the leftmost bit is 1 then fill with 1
• Conditional(Ternary) Operator:
Syntax: condition(relational expression) ? Expression 1 : Expression 2
If condition evaluates to true then result will be Expression 1 otherwise Expression 2
{ } used to define block or to declare array with static elements
[ ] used to declare array variable
( ) used to define/call function or used in expressions
; used to terminate a statement
, used to separate variables in declaration
. used to access data members and member functions of an object or class

More Related Content

PPTX
Overview of c language
PPTX
Overview of c++ language
PPTX
C++ Overview PPT
PPT
Introduction to C++
PPT
C++ programming
PPTX
Getting started in c++
PPSX
Esoft Metro Campus - Programming with C++
PPTX
Storage classes in c language
Overview of c language
Overview of c++ language
C++ Overview PPT
Introduction to C++
C++ programming
Getting started in c++
Esoft Metro Campus - Programming with C++
Storage classes in c language

What's hot (20)

PPT
Lecture 14 - Scope Rules
PPT
Lecture 13 - Storage Classes
PPTX
2.overview of c#
PDF
C language
PPT
C++ for beginners
PDF
Client sidescripting javascript
PPT
Declaration of variables
PDF
Python unit 2 as per Anna university syllabus
PPSX
Complete C programming Language Course
PPTX
Function C programming
PPTX
Introduction to Basic C programming 02
PPSX
Complete C++ programming Language Course
PPTX
Spf Chapter4 Variables
PPSX
DITEC - Programming with Java
PPTX
Spf Chapter5 Conditional Logics
PPT
Lecture 11 - Functions
PPTX
Python Training in Bangalore | Python Introduction Session | Learnbay
PDF
C language for Semester Exams for Engineers
ODP
(2) c sharp introduction_basics_part_i
PPT
Getting started with c++
Lecture 14 - Scope Rules
Lecture 13 - Storage Classes
2.overview of c#
C language
C++ for beginners
Client sidescripting javascript
Declaration of variables
Python unit 2 as per Anna university syllabus
Complete C programming Language Course
Function C programming
Introduction to Basic C programming 02
Complete C++ programming Language Course
Spf Chapter4 Variables
DITEC - Programming with Java
Spf Chapter5 Conditional Logics
Lecture 11 - Functions
Python Training in Bangalore | Python Introduction Session | Learnbay
C language for Semester Exams for Engineers
(2) c sharp introduction_basics_part_i
Getting started with c++
Ad

Viewers also liked (20)

PDF
Learn Java Part 1
PPTX
Introduction to java
PDF
Learn Java Part 11
PDF
Learn Java Part 6
PDF
Learn Java Part 9
PDF
PDF
Learn Java Part 8
PDF
Learn Java Part 7
PDF
Learn Java Part 5
PDF
Learn Java Part 4
PDF
Learn Java Part 10
PDF
Defing locations in Oracle Apps
PDF
Assigning role AME_BUS_ANALYST
PDF
Creating business group in oracle apps
PPTX
Introduction to Java Programming
PDF
Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...
PPT
Tracking and positioning of mobile systems in telecommunication networks
PPTX
Introduction to Jquery
PDF
International Journal of Electrical Power System and Technology vol 2 issue 1
PPT
GSM Architecture
Learn Java Part 1
Introduction to java
Learn Java Part 11
Learn Java Part 6
Learn Java Part 9
Learn Java Part 8
Learn Java Part 7
Learn Java Part 5
Learn Java Part 4
Learn Java Part 10
Defing locations in Oracle Apps
Assigning role AME_BUS_ANALYST
Creating business group in oracle apps
Introduction to Java Programming
Java Progamming Paradigms, OOPS Concept, Introduction to Java, Structure of J...
Tracking and positioning of mobile systems in telecommunication networks
Introduction to Jquery
International Journal of Electrical Power System and Technology vol 2 issue 1
GSM Architecture
Ad

Similar to Learn Java Part 2 (20)

PPT
PRAGRAMMING IN JAVA (BEGINNER)
PDF
Chapter 01 Introduction to Java by Tushar B Kute
PPTX
ChapterTwoandThreefnfgncvdjhgjshgjdlahgjlhglj.pptx
PPT
Data types and Operators
PPTX
Java chapter 2
PPT
Operator & Expression in c++
PPTX
Java fundamentals
PPTX
Java_Programming_Concepts_Full_P22_P60.pptx
PPTX
Lecture-02-JAVA, data type, token, variables.pptx
PPTX
Java Basic Elements Lecture on Computer Science
PPTX
Fundamental programming structures in java
PPTX
Guide to Java.pptx
PPTX
Operators1.pptx
PPTX
Fundamentals of computers - C Programming
PPTX
C++ revision add on till now
PPTX
C++ revision add on till now
PPT
lecture2 (1).ppt variable s and operators
PPTX
Java Operators with Simple introduction.pptx
PPT
JAVA Variables and Operators
PRAGRAMMING IN JAVA (BEGINNER)
Chapter 01 Introduction to Java by Tushar B Kute
ChapterTwoandThreefnfgncvdjhgjshgjdlahgjlhglj.pptx
Data types and Operators
Java chapter 2
Operator & Expression in c++
Java fundamentals
Java_Programming_Concepts_Full_P22_P60.pptx
Lecture-02-JAVA, data type, token, variables.pptx
Java Basic Elements Lecture on Computer Science
Fundamental programming structures in java
Guide to Java.pptx
Operators1.pptx
Fundamentals of computers - C Programming
C++ revision add on till now
C++ revision add on till now
lecture2 (1).ppt variable s and operators
Java Operators with Simple introduction.pptx
JAVA Variables and Operators

More from Gurpreet singh (19)

PDF
Oracle Fusion REST APIs with Get Invoice API example
PDF
PL/SQL for Beginners - PL/SQL Tutorial 1
PDF
Creating ESS Jobs for Oracle Fusion BIP Reports
PDF
Introduction to Oracle Fusion BIP Reporting
PDF
Why Messaging system?
PDF
Understanding Flex Fields with Accounting Flexfields(Chart of Accounts) in O...
PPTX
Oracle Application Developmenr Framework
PDF
Java Servlet part 3
PDF
Oracle advanced queuing
PDF
Oracle SQL Part 3
PDF
Oracle SQL Part 2
PDF
Oracle SQL Part1
PDF
Generics and collections in Java
PDF
IO Streams, Serialization, de-serialization, autoboxing
PDF
Java Servlets Part 2
PDF
Introduction to Data Flow Diagram (DFD)
PDF
Ingenium test(Exam Management System) Project Presentation (Full)
PDF
Computer Graphics Notes
PDF
Learn Java Part 11
Oracle Fusion REST APIs with Get Invoice API example
PL/SQL for Beginners - PL/SQL Tutorial 1
Creating ESS Jobs for Oracle Fusion BIP Reports
Introduction to Oracle Fusion BIP Reporting
Why Messaging system?
Understanding Flex Fields with Accounting Flexfields(Chart of Accounts) in O...
Oracle Application Developmenr Framework
Java Servlet part 3
Oracle advanced queuing
Oracle SQL Part 3
Oracle SQL Part 2
Oracle SQL Part1
Generics and collections in Java
IO Streams, Serialization, de-serialization, autoboxing
Java Servlets Part 2
Introduction to Data Flow Diagram (DFD)
Ingenium test(Exam Management System) Project Presentation (Full)
Computer Graphics Notes
Learn Java Part 11

Recently uploaded (20)

PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
OOP with Java - Java Introduction (Basics)
DOCX
573137875-Attendance-Management-System-original
PPTX
Welding lecture in detail for understanding
PPT
Mechanical Engineering MATERIALS Selection
PPTX
Geodesy 1.pptx...............................................
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Well-logging-methods_new................
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PDF
ETO & MEO Certificate of Competency Questions and Answers
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
OOP with Java - Java Introduction (Basics)
573137875-Attendance-Management-System-original
Welding lecture in detail for understanding
Mechanical Engineering MATERIALS Selection
Geodesy 1.pptx...............................................
CYBER-CRIMES AND SECURITY A guide to understanding
Well-logging-methods_new................
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Lesson 3_Tessellation.pptx finite Mathematics
ETO & MEO Certificate of Competency Questions and Answers
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Lecture Notes Electrical Wiring System Components
Foundation to blockchain - A guide to Blockchain Tech
CH1 Production IntroductoryConcepts.pptx
Unit 5 BSP.pptxytrrftyyydfyujfttyczcgvcd
additive manufacturing of ss316l using mig welding
Fluid Mechanics, Module 3: Basics of Fluid Mechanics

Learn Java Part 2

  • 1. Java Tokens: Keywords, Identifiers, Literals, Operators, and Seperators
  • 2. A smallest individual unit in source code is known as Token Java Tokens Keywords Identifiers Literals Operators Seperators
  • 3. Keywords are special tokens in the language which have reserved use in the language. Keywords may not be used as identifiers in Java — you cannot declare a field whose name is a keyword, for instance. Java has 50 keywords among which 48 are in use but 2 (goto and const) are currently not in use Here is a list of keywords in the Java programming language. You cannot use any of the following as identifiers in your programs. The keywords const and goto are reserved, even though they are not currently used. true, false, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs. abstract continue for new switch assert*** default goto* package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum**** instanceof return transient catch extends int short try char final interface static void class finally long strictfp** volatile const* float native super while * not used ** added in 1.2 *** added in 1.4 **** added in 5.0
  • 4. Identifiers are the names of variables, methods, classes, packages and interfaces. • Don’t use a keyword • Don’t use a space • Don’t use a special symbol other than ( _ and $ ) • Cannot start with digit • Any length • If only a single word then use a lowercase • If more than one word then start first word with lowercase and other words start with first letter as Capital For example: int balance=500; //Single word int bankBalance=500; //Multiple Words
  • 5. • Use lowercase For example: package pack1; package mypack1; • Every word start with first letter as Capital For example: class Balance{} class BankBalance{} • Use Uppercase and Underscore for separating the words For example: int PI=3.14; int MAX_VALUE=100;
  • 6. Fixed value assigned to variables or used in expressions is known as Literals • Integer Literals: for example: 1, -2, 8523, -2105 etc. Data Type Size Range byte 1 Byte -27 to 27 -1 short 2 Bytes -215 to 215 -1 int 4 Bytes -231 to 231 -1 long 8 Bytes -263 to 263 -1 • Floating Literals: for example: 1.02, -2.689, 8523.369, 2105 etc. Data Type Size Range float 4 Byte -3.4 * 1038 to 3.4 * 1038 double 8 Bytes -1.7 * 10308 to 1.7 * 10308
  • 7. • Character Literals: for example: ‘A’, ‘B’, ‘@’, ‘&’ etc. Data Type Size Range char 2 Bytes All Unicode characters • String Literals: for example: “Hello”, “Gurpreet Singh”, “ACET” etc. Data Type Size Range String 2 * No. of characters As much memory available • Boolean Literals: true and false. Data Type Size Range boolean 1 Byte true or false • Null Literals: null can be assigned to any reference type
  • 8. Operators operates on operands. For example: In expression a+b , a & b are operands and + is operator • Arithmetic Operator: +, - , *, /, %. For example: 5+4 will result in 9 5-4 will result in 1 5*4 will result in 20 5/4 will result in 1 5%4 will result in 1 (remainder) -5%4 will result in -1 5%-4 will result in 1 -5%-4 will result in -1 Note: Sign of result in % operator depends on the sign of dividend(numerator) • Relational Operator: <, >, <=, >=, ==, != Output will be either true or false 5>6 will result in false 5>=6 will result in false (either greater than or equal to) 5<6 will result in true 5<=6 will result in true (either less than or equal to) 5==6 will result in false (equal to) 5!=6 will result in true (not equal to)
  • 9. • Assignment Operator: = Assign the value on left hand side to right hand side. For example: A=10+5, will assign 15 to A • Logical Operator: returns true or false Logical AND (&&) Logical OR (||) Logical NOT (!) A B A&&B A||B !A true true true true false true false false true false false true false true true false false false false true • Increment/Decrement Operator: increases or decreases the value by 1 Pre-increment & Pre-decrement: ++a, --a Post-increment & Post-decrement: a++, a--
  • 10. • Bitwise Operator: Performs operations on bits Bitwise AND(&) Bitwise OR(|) Bitwise XOR(^) Bitwise Complement or Not (!) A B A&B A|B A^B !A 0 0 0 0 1 1 0 1 0 1 0 1 1 0 0 1 0 0 1 1 1 1 1 0 • Shift Operator: shift the bits to left or right Left Shift(<<): shifts the bits to left and fill the vacant spaces with 0 Unsigned Right Shift(>>>): shifts the bits to right and fill the vacant spaces with 0 Signed Right Shift(>>): shifts the bits to right and fill the vacant spaces with leftmost bit, i.e. if leftmost bit is 0 then fill with 0, and if the leftmost bit is 1 then fill with 1 • Conditional(Ternary) Operator: Syntax: condition(relational expression) ? Expression 1 : Expression 2 If condition evaluates to true then result will be Expression 1 otherwise Expression 2
  • 11. { } used to define block or to declare array with static elements [ ] used to declare array variable ( ) used to define/call function or used in expressions ; used to terminate a statement , used to separate variables in declaration . used to access data members and member functions of an object or class