First Program in Java | Core Java Tutorials

This Core Java Tutorials you are able to learn”How to write First Program in Java? ” clearly explains how to write simple java program using java language syntactical rules and clearly explains all the parts of java program.


First Java application:

  • Java programming language is case sensitive.
  • Look at the capital letters in the following program.
  • Some of the Naming conventions (discussion later) we need to follow to write programs.

First Java program



  • Java Application is a collection of Classes.
  • Class represents Object.
  • We are defining objects in Application to communication using classes.
  • Every java instruction must belongs to class.


Class Identity: (FirstApplication)

  • Every application is a set of class files.
  • Hence every class should be uniquely identified by JVM.
  • JVM executes a specific class using its identity only.


Why java class name starts with capital letter ?

  • Java API is a set of classes.
  • All these classes follow a naming convention rule “CAMEL CASE WITH NO SPACE”.
  • In case of pre-defined class, we must follow this rule.
  • In case of user defined class, naming convention rule is optional(but recommended).
  • We have to face problems if we violate the convention rules while writing application.
  • To use the functionality of these classes, first we have to study API.
  • Description of these classes will not be available along with JDK installation.
  • Oracle Company provided documentation about these classes as an OFFICIAL WEBSITE

Class Naming Convention in Java



  • Every java developer should maintain this documentation to develop java applications.
  • Instead of searching the documents online, free downloads available for basic java developers.
  • Instead of maintain data connection (internet) we can go for website downloads.


Why main method is public & static?

  • Main method is the common(static) starting point of all(public) the applications.
  • Hence it is public static.


Why main method return type is void?

  • JVM invokes main() method to start application execution.
  • main() method is not returning anything to JVM, Hence it is void.
  • Method naming convention “MIXED CASE & NO SPACE”
  • Examples :
    next( )
    nextFloat( );
    getAccountHolderName( );
  • In case of pre-defined methods, we must follow convention rules.
  • In case of user-defined methods, these rules are optional(but recommended to follow)


Signature of main method:

  • List of arguments is called signature.
  • Generally all the programs in a computer execute in OS environment(DOS).
  • It is just like C and C++ command line arguments process concept only.
  • We will discuss about “Command line arguments” later.

Command Line arguments in Java


Share this