-7

Why am I getting an error in this code please help me out. Error is coming that

could not find symbol thread.sleep

here is the code:

  import java.util.Date;
  class Date_Time
    {
      public static void main(String[] args)
      throws Throwable
     {
          while(true)
          {
             Date_Time d= new Date_Time();
             System.out.print(d);
             thread.sleep(500);
             System.out.println("\r");
             thread.sleep(500);
          }
      }
    }
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

2 Answers2

0

In Java it's Thread.sleep(500); with capital letter.

Edit

Date_Time is your class. If you want to print the date you need to use Date library

Date d = new Date();
System.out.print(d);
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Guy
  • 46,488
  • 10
  • 44
  • 88
0

d is a class, so if you print a class you will get the tostring representation of it, so modify the class,(override the toString method and return what you need to from it)

import java.util.Date;
class Date_Time{
    public static void main(String[] args) throws Throwable {
        while(true){
            Date_Time d= new Date_Time();
            System.out.print(new Date());
            thread.sleep(500);
            System.out.println("\r");
            thread.sleep(500);
        }
    }
}
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97