

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Keywords in Java
Keywords in Java are reserved words that represent predefined actions, internal processes etc. Because of this, keywords cannot be used as names of variables, functions, objects etc.
The main difference between keywords and identifiers is that keywords are reserved words that represent predefined actions while identifiers are the names of variables, functions, objects etc.
Some of the keywords in the Java are given as follows −
abstract | assert | boolean | break |
byte | case | catch | char |
class | const | continue | default |
do | double | else | enum |
extends | final | finally | float |
for | goto | if | implements |
import | instanceof | int | interface |
long | native | new | package |
private | protected | public | return |
short | static | strictfp | super |
switch | synchronized | this | throw |
throws | transient | try | void |
volatile | while |
A program that demonstrates keywords is given as follows −
Example
public class Example { public static void main(String[] args) { int i = 5; char c = 'A'; System.out.println("i = " + i); System.out.println("c = " + c); } }
Output
i = 5 c = A
Now let us understand the above program.
The keywords in the above program are int and char that specify integer and character data types respectively. Also i and c are identifiers.
In the above program, the values of i and c are defined and then they are printed. The code snippet that demonstrates this is given as follows.
int i = 5; char c = 'A'; System.out.println("i = " + i); System.out.println("c = " + c);
- Related Questions & Answers
- Are true and false keywords in java?
- Keywords in C#
- Keywords in Python
- C++ Keywords
- Difference Between extends and implements keywords in Java
- Important Keywords in C#
- Reserved keywords in C++?
- What are the different types of keywords in Java?
- Variables and Keywords in C
- Are ‘this’ and ‘super’ keywords in Java?
- What is the difference between super and this, keywords in Java?
- What is the difference between throw and throws keywords in Java?
- What is the difference between keywords and reserved words in Java?
- char vs string keywords in C#
- What are reserved keywords in C#?