Keywords are some special names which are reserved by JAVA, We can not use that names to create variables,classes or methods. They have their different meanings. for example ”class”, its reserved by JAVA. This keyword is used to create new class but if we try to use that name for our class then its impossible.
for example if we make a class like this example :
class class{public static void main(String[] args){System.out.println("Hello");}}
and when you try to run this code then you will get below error :
_class.java:1: error: <identifier> expected_
as shown in below screenshot.
here is list by categories :
Category | Keywords |
---|---|
Access modifiers | private, protected, public |
Class, method, variable modifiers | abstract, class, extends, final, implements, interface, native, new,static, strictfp, synchronized, transient, volatile |
Flow control | break, case, continue, default, do, else, for, if, instanceof, return,switch, while |
Package control | import, package |
Primitive types | boolean, byte, char, double, float, int, long, short |
Error handling | assert, catch, finally, throw, throws, try |
Enumeration | enum |
Others | super, this, void |
Unused | const, goto |
These are keywords in java, each and every keyword have its special task. for example ’class’ keyword is used to create Classes in java. It is impossible to create Class without using ’class’ keyword.
Quick Links
Legal Stuff
Social Media