aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Numeric Literals that include a comma Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Numeric Literals that include a comma" Watch "Numeric Literals that include a comma" New topic
Author

Numeric Literals that include a comma

Anitha Lingam
Ranch Hand

Joined: Apr 21, 2002
Posts: 38
Hi,

Numeric literals that include a comma, for example,
int x = 25,343; // Decimal
int y = 0x1,1; // Octal

The above lines doesn't compile because of the comma.

But,
int x = 0xa,b // Octal

doesnot give a compile time error. Why?
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
int x = 0xa,b; // Octal


This is equivalent to:


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Deepa Korecherla
Ranch Hand

Joined: Jul 14, 2004
Posts: 197
Originally posted by Ashwatha K:
Hi,

Numeric literals that include a comma, for example,
int x = 25,343; // Decimal
int y = 0x1,1; // Octal

The above lines doesn't compile because of the comma.

But,
int x = 0xa,b // Octal

doesnot give a compile time error. Why?

-----------------------------

In the line, int x= 25,343;
compiler assumes like this, x = 25 and assumes 343 as another var. which is not a legal variable name. same for the next line. learn about the legal var. names.
var. names can only start with _ or $ or any alphabet.but not number.


DKR<br />SCJP1.2,SCWCD1.4,SCBCD1.3,SCJA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Numeric Literals that include a comma