1. White Space in Java
Java programs use white space to separate the words and symbols. White space consists of:
- blanks
- tabs
- newline characters
Except when it’s used to separate words, the Java compiler ignores white space, and the white space doesn’t affect the execution of the program. For this reason, we can write a program in many ways!
For an example, you can put all of the Java statements in a program into one single line, and it will compiler and run as long as the program contains no error. Of course, it would be a bad style!
Let’s use the HelloWorld.java as an example!
Example #1:
The HelloWord.java can be written in the following style, with white space to separate each word or symbol, line breaks to start a new line for each statement, and indentation to indicate each code blocks.
public class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello, World!”);
}
}
Example #2:
Because the Java compiler ignores white space, we can also write all of the statements into one single line and it will work (compile and run), but would be difficult to read and debug!
public class HelloWorld { public static void main(String[] args) { System.out.println(“Hello, World!”); }}
2. Adding Comments
According to Wikipedia, In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program. They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters.
You can add either a comment that spans several lines, or a single line comment. Here are some examples of Java comments:
3. Identifiers in Java
- What are Identifiers?
- As the name suggests, Identifiers are symbolic names used for the identification!
- Identifiers in Java can be the names of of variables, methods, classes, packages and interfaces.
- What are some examples of Java Identifiers?
- Example #1:
In the HelloWorld program, HelloWorld, String, args, main and println are identifiers.
-
- Example #2:

4. Java Reserved Words
- In Java, a number of words are reserved for a special purpose.
- All Java reserved words use only lowercase letters.
- Reserved words should ONLY be used in its strictly prescribed way, because each reserved word has a particular meaning.
- According to Oracle, here is a complete list of Java Reserved Words (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 |
| * | not used | |
| ** | added in 1.2 | |
| *** | added in 1.4 | |
| **** | added in 5.0 |
List of Citations, Sources and References:
- https://data-flair.training/blogs/identifiers-in-java/
- Lewis, Java Software Solution, 3rd Edition
- https://www.knowprogram.com/java/identifiers-in-java/