Before start programming

Things you must know before start Programming

Programming Tutorials
Share to others

I think you are now satisfy with your first program. If you are not complete it, click here. but there are some things that you must know before start Java Programming, you have to study about these things, if not it may misguide you at some points. So, read this carefully.

Man method

Java main method is the entry point of any java application program.

  1. Signature of the main method
public static void main(String []arg)
	//method body
  1. Rules of the main method
  • Entry point for a java application.
  • Required by all java applications (not required in Applets).
  • Must be declared public static void.
  • void must be appear before main().


public static void main(String []arg){}   //legal
static public void main(String []arg){}   //legal
public void static main(String []arg){}   //illegal

Sub Rules:

  1. Can also be declared final. (This will be explained later in modifiers).
  2. main() has only one argument: a String array.
  3. The argument can be declares in many ways and the variable name does not have to be args.


public static void main(String []arg){} 
public static void main(String [] args){}
public static void main(String arg[]){}
public static void main(String[] params){}
public static void main(String[] args){}  //standard convention

Lexical Structure

The lexical structure of a programming language is the set of elementary rules that define what are the tokens or basic atoms of the program. It is lowest level syntax of a language and specifies what are punctuations, reserved words, constant and operators.

  1. Java is case sensitive.
  2. Whitespace, tab, and newline characters are ignored except when part of string constant. They can be added as needed for readability.
  3. Comments (3 types)
  • Single line comments begin with //
  • Multi-line comments begin with /* and ends with */
  • Documentary comments begin with /** and ends with **/
//this is single line comment
  1. Statements terminate in semicolons (;), make sure to always terminate statements with semicolon.
System.out.println("At the end there is a semi colon");
int y = 19; //ends with semi colon
  1. Commas are used to separate words in a list.
public void getSum(int y, int x, int z)   //commas are used
      //method body
  1. Round brackets are used to operate precedence and argument lists.
  2. Square brackets are used to arrays and square bracket notation.
  3. Curly or brace brackets are used for blocks.
public static void main(String[] arg)
    //method body
/*this is simplest example to demonstrate all types of brackets and their uses*/
  1. Keywords are reserved words that have special meanings within the language syntax.
  2. Keywords are reserved words for constant, variables, functions, properties, method and objects. The first character must be a letter, underscore or dollar sign. Following characters can also include digits.


•	abc  	//legal
•	$abc	//legal
•	_abs	//legal
•	34abc	//illegal
•	@as3	//illegal
•	_$as34	//legal

Java Reserved Word list

Here is a list of keywords in the Java programming language. You cannot use any of the following as identifiers in your program. The keywords cont and goto are reserved, even though they are not currently used.

abstract continue For new switch
assert default package synchronized goto
boolean do if private this
break double implements protected throws
byte else import public throw
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

true, false, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your program.

As you know java is case sensitive programming language. So, you can use above reserved words by changing the first letter to capital or simple. But, good programmers didn’t do that. So, keep the above tips in your mind before start programming.

Share to others