class Demo implements Runnable
{
public static void main(String args[])
{
//Create the object of Demo class.
Demo obj1 = new Demo()
Thread t1 = new Thread(obj1);
t1.start();
try
{
t1.sleep(1000);
}
catch(InterruptedException e)
{}
}
This code works.
Question : Even if sleep() method is static,we are accessing it via object of the class.why??
{
public static void main(String args[])
{
//Create the object of Demo class.
Demo obj1 = new Demo()
Thread t1 = new Thread(obj1);
t1.start();
try
{
t1.sleep(1000);
}
catch(InterruptedException e)
{}
}
This code works.
Question : Even if sleep() method is static,we are accessing it via object of the class.why??