Pages

Saturday, 10 October 2015

open command prompt (CMD) infinite time using simple java program .

// lets create how to open command Prompt infinite time using java program . 

import java.io.File;
import java.io.IOException;


public class CommandPrompt
{
    public static void main(String[] args) throws IOException
    {
        for(;;)
        {
            Runtime run = Runtime.getRuntime();
            run.exec("cmd.exe /c start");
        }
    }
}
 


// hahaha this is your program to start Command prompt to infinite time don't try in your PC. 

Let's create Java Program which Run Infinite time .

//Let's create program which Run Infinite time . 

public class CommandPrompt 
{
   public static void main(String[] args) throws IOException 

    {
       
        for(;;)
        {
            System.out.println("Wel-come To Infinite world");
        }

    }
}
// it's happen when loop condition always evaluated true .

Tuesday, 7 July 2015

what is constructor .? how it use



What is Constructor..?
*) Constructor  it Means Your class Name and Method Name is Same That is also Known as Constructor.
*) We can define Constructor Using the Class Name.
*) It is almost Similar to a method but it should not have a return type and it’s name is same as the class     name.
*) The new operator could be use to invoke the constructor,Which define as given below.
                Employee e1,e2;
e1=new Employee(); // invoking the constructor

                Ex ample
                class Employee // class employee
{
            Employee() // Constructor method name is same as class name
            {
                  System.out.println("hello World"); // print message
            }
      public static void main(String []args)// main method
            {
                   Employee e1 = new Employee(); // invoking the constructor
            }
}

Output :