Home » Home » What is Identifiers, Modifiers, Program, Keywords, Comments in Java ?

What is Identifiers, Modifiers, Program, Keywords, Comments in Java ?

Java Identifiers :

Definition : Every program required data so we store data but where that is identifiers, Identifiers have unique name and we store our literals that is data on those name and we can easily access it by name.

All java components require names. Names used for classes, variables and methods are called identifiers. In java there are several points to remember about identifiers. They are as follows :

  • All identifiers should begin with a letter (A to Z or a to z ), currency character ($) or an underscore ().
  • After the first character identifiers can have any combination of characters.
  • A key word cannot be used as an identifier.
  • Most importantly identifiers are case sensitive.
  • Examples of legal identifiers: age. $salary. value._1_value
  • Examples of illegal identifiers: 123abc, -salary

Java Modifiers :

Definition :

Like other languages it is possible to modify classes. methods etc by using modifiers. The modifiers are used to kept data according to user requirement and share to whom you want. There are two categories of modifiers

  • Access Modifiers: default, public, protected, private
  • Non-access Modifiers: final, abstract

Program : Program is instruction written by programmer to be executed line by line and when program is in execution state called process.

My first File of Java : SAMPLE

Things to notice when we creating our Java Files :

  • Java file extension always is .java like MyFirstFile.java .
  • There are always one class that have Access Modifier as public that must of name of file.
  • One file always contain only one main method.
public class MyFirstFile {

/* This is my first java file
 * This will print 'Hello World' as the output

    public static void main(String[] args) {

        System.out.println("Hello Java Readers");


Lets look at how to save the file, compile and run the program. Please follow the steps given below:

  • Open notepad and add the code as above.
  • Save the file as: MyFirstJavaProgram.java.
  • Open a command prompt window and go o the directory where you saved the class. Assume its C:\
  • Type javac MyFirstJavaProgram.java and press enter compile your code. If there are no errors in your code the command prompt will take you to the next line.(Assumption The path variable is set).
  • Now type java MyFirstJavaProgram to run your program.
  • You will be able to see Hello World printed on the wind
  • C:> javac MyFirstJavaProgram java
  • C:>java My First Java Program

Hello World

Java Keyword : The following list shows the reserved words in Java. These reserved words may not be used as constant or variable or any other identifier names.

Comments in Java: Java supports single line and multi-line comments very similar to c and c++. All characters available inside any comment are ignored by Java compiler.

Comments are ignored by compiler of java (javac). Their only work is for other programmer to them understand easily and they are nothing to compiler. But they are very useful to other programming when they are working on same projects with many people.

public class MyFirstFile {

    *This is my first java program
    *This will print "Hello Java Readers" as Output
    **This is the example of Multi-line Comments

    public static void main(String[] args) {

        // This is single line comments 
        System.out.println("Hello Java Readers");



Related Posts

Leave a Reply

%d bloggers like this: