Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Are true and false keywords in java?
Keywords − Keywords in Java convey a special meaning to the compiler therefore, these cannot be used as identifiers. Java provides a set of 50 keywords.
| 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 |
Reserved words − Among the list of key words list mentioned above the key words goto and const are currently not in use. They are reserved words (for the future use).
The true false and null − True, false and null represents certain values in Java, they are used as literals. They are not considered as keywords.
Still, you cannot use them as identifiers in Java if you try to do so, a compile time error will be generated.
Example
public class Example {
public static void main(String args[]) {
int true = 20;
int false = 30;
float null = 23.6f;
}
}
Output
Example.java:3: error: not a statement
int true = 20;
^
Example.java:3: error: ';' expected
int true = 20;
^
Example.java:4: error: not a statement
int false = 30;
^
Example.java:4: error: ';' expected
int false = 30;
^
Example.java:5: error: not a statement
float null = 23.6f;
^
Example.java:5: error: ';' expected
float null = 23.6f;
^
6 errors Advertisements
