views:

281

answers:

5

I am using quartz for schedulling.

TriggerUtils.getDateOf(0,40,18,09,06); it accept 5 parameter. (seconds, minutes, hours, daysOfMonth, month).

When i pass fourth parameter as "09". Eclipse give me error "The literal Octal 09 (digit 9) of type int is out of range ".

But when i pass the fourth parameter as "9" instead of "09", it works.

Can anyone explain me this error?

+16  A: 

There is no 9 in Octal (what you get with a preceding 0). 0-7, only.

Eric
+10  A: 

Numbers that begin with the zero digit are treated as octal (base 8) literals, and 9 is not a valid octal digit.

anon
+11  A: 

When you precede a number with 0 ("09" rather than "9"), then Java (and C and many other languages) interpret the number to be in octal - base-8.

"09" is not a valid number in octal - any single digit can be a maximum of "7" (since in octal, numbers go from 0..7).

rascher
+15  A: 

In java, if you are defining an integer, a leading '0' will denote that you are defining a number in octal

int i = 07; //integer defined as octal
int i = 7; // integer defined as base 10
int i = 0x07; // integer defined as hex
James Van Huis
I didn't know about "0b". Does that work in C, too?
rascher
The 0b prefix doesn't exist yet; it's a possible extension to Java 7.
gustafc
Ah, thanks. Fixed.
James Van Huis
+2  A: 

10 is how many digits you have, whereas 010 is is what you get if you don't count your thumbs.

JustJeff