Hi all,  I seem to be having trouble with the following code for the
homework.  Does anyone know why I am getting the error?

 

import java.util.Date;

 

public class MyCurrentDate extends Thread implements Runnable {

 

    Date date;

 

    MyCurrentDate(Date date) {

        date = this.date;

        

    }

 

    public void run() {

        for (int i = 0; i < 10; i++) {

            System.out.format("DONE! %s%n", date.toString());

            try {

                sleep(100);

            } catch (InterruptedException e) {}

        }

    }

}

 

I get the following error on the System.out.format line:

 

Exception in thread "Thread-5" Exception in thread "Thread-1"
java.lang.NullPointerException

        at MyCurrentDate.run(MyCurrentDate.java:14)

        at java.lang.Thread.run(Thread.java:619)

 

Jon Carlson P.E.

Engineering Director

CC Technics, Inc.

253-250-1600 cell

253-473-9295 office

253-476-2712 fax

 <mailto:[email protected]> [email protected]

 <http://www.cctechnics.com> www.cctechnics.com

 

DISCLAIMER:

This message is confidential, intended only for the named recipient(s) and
may contain information that is privileged or exempt from disclosure under
applicable law. If you are not the intended recipient(s), you are notified
that the dissemination, distribution or copying of this information is
strictly prohibited. If you received this message in error, please notify
the sender then delete this message.

 


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to