Labels

Monday, September 28, 2015

Program to print an integer

Open Notepad and type the following:-

public class ex2
{
    public static void main(String [] args)
    {
        int num;
        num=100;
        System.out.println("The number is "+num);
     }
}



  1. Save the file in desktop.
  2. Open cmd in windows or terminal in Linux.
  3. In windows enter cd desktop
  4. to compile enter javac <file_name>.java   //in this condition this is ex2.
  5. then enter java <file_name>   // to run the bytecode.

No comments:

Post a Comment