Once you click post assignment, learners in the selected class will immediately be able to see and complete this assignment
Back to Classroom
Reserved words
Introduction To Java Course
Engineers From These Top Companies and Universities Trust EXLskills
1M+ Professionals | 100+ Institutions
This is the EXLskills free and open-source Introduction To Java Course. It guides learners via explanation, demonstration, and thorough practice, from no more than a basic understanding of Java, to a moderate level of essential coding proficiency.
Is this course FREE?
Yes, this a 100% free course that you can contribute to on GitHub here!
In Java, there are keywords that are reserved for the use of Java functions or other uses that cannot be identifiers like variables, classes and function names. When a reserved word is used as a variable, we will get an error or some other unexpected result. Examples of reserved words are shown below.
ReservedWordsExample.java
package exlcode;
public class ReservedWordsExample {
public static void main(String[] args) {
String exampleVariable = "George";
// This prints Hello World! and exampleVariable
System.out.println("Hello World!");
System.out.println(exampleVariable);
}
}
In our example above, we see that the reserved words are in a different color than the rest of the line. These are words that have a specific meaning to the system. For example, class means that a definition of "class" immediately follows. We must use reserved words only for their intended purpose; we cannot use "class" for any other purpose than defining class.
Please notice that the Java reserved word must be written in the exact same way as Java states, including the case of the word. For this reason, even though it is not recommended, we could technically name a variable "Class" because the 'C' is capitalized so it is not our reserved word class.
The following are more examples of reserved words that we will learn how to use as we progress through the course.