Just a tad bit of Java
IDENTIFIERS AND RESERVED WORDS

Let’s talk about a little code snippet first, we can have a formal introduction later.

My question to you is, does this code compile correctly? If you are one of my favourite kinds, then there are two answers to this question. False, thinking how can one use String as an identifier? True, knowing the logic behind naming conventions. This code will compile perfectly.

The beauty about misconceptions are, you do not harness one until you know it is one. This blog, and many more to come, will talk about these misconceptions. Due to my familiarity with Java, a stretch of these blogs will dwell in the aforesaid language. The articles will be structured from beginner to advanced concepts. This article will talk about the basics of identifiers and reserved words.
Identifiers are the names given to variables, classes, functions and labels which help distinguish one from the other. An analogy for the use of identifiers is the names given to us humans, Aritra (that is me) is an identifier that distinguishes me from you,(please do not be another Aritra and let me live with my analogy). Let us now look into a little code snippet.

If I asked you how many identifiers are there in the above code snippet? 1? 2? or 3? 3 yes? What if I told you 4? or a 5?
People who are still clinging on to this nuisance that I call a blog, the answer is 5. The basic identifiers that everyone has correctly identified (look what I did there?) are Test, main, x and args. String is also an identifier. As I have mentioned earlier that a name of a class, function, variable and a label are termed as identifiers. String is a predefined class name hence is also an identifier.
Reserved Words: Reserved words are the tokens that cannot be used as an identifier. These words are kept reserved for depicting special meaning. A basic flowchart might help readers understand the Java Reserved Words tree better.

Reserved Words can be broken down into two sets, Keywords and Reserved Literals. When we want to depict some functionalities with reserved words we cluster them into Keywords. When the reserved words depict values the collection is called Reserved Literals.

null being one of the reserved literals is the default value of an object reference. true and false are the other reserved literals, both of them are boolean literals used for logical conditions.
Reserved Words → Unused Keywords: These keywords are not used in the Java Language. The two keywords goto, const have no meaning in the Java Programming Language, yet they cannot be used as an identifier. These are like the landmines we do not want to tread on.
Reserved Words →Used Keywords: These keywords are used in the Java Language. For the sake of better visualisation please refer to the diagram below. The diagram provides a tree of the used keywords.

Looks like something is missing. You got me. The used keyword enum is missing. I purposely took this keyword out of the tree diagram. Enums came late into the language and serve a rather beautiful concept. enum is used to describe a collection of constants. A little code snippet you may ask?

Case Sensitivity: Java is considered to be a case sensitive language. A real essence to this statement can only be depicted by a code snippet.


null being a reserved word invokes an error while compiling. Null depicts how Java treats it as a valid identifier as the case is tweaked a little.
I will draw a line to my article now. Hope to be a source of your opening some tabs and researching about identifiers and reserved words. The logic to the first question is left to the reader to solve. Happy coding :)