Hi there..

In sleep(5000) what type of data is 5000??? Is that an integer or byte or something.
Thanks in advance

Recommended Answers

All 3 Replies

long

Edit: As if the API docs for Thread couldn't have told you that, or what that number represents.

http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html

static void sleep(long millis): causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers.

Actually, maybe this was a trick question on an SCJP type exam. It is suppossed to take a long, but a bare, non-decimal number hord-coded into code that way is an int (accepted by the method due to the "widening" principle).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.