aspose file tools*
The moose likes Beginning Java and the fly likes Problem in the code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem in the code" Watch "Problem in the code" New topic
Author

Problem in the code

Ganesh Kumar
Ranch Hand

Joined: Jul 02, 2007
Posts: 113
Hi,
When i execute this code mon=08,mon=09 shows error. Can any one say me what is the problem here


int mon = 0;
if(Month.equals("Jan"))
mon=01;
else if(Month.equals("Feb"))
mon=02;
else if(Month.equals("Mar"))
mon=03;
else if(Month.equals("Apr"))
mon=04;
else if(Month.equals("May"))
mon=05;
else if(Month.equals("Jun"))
mon= 06;
else if(Month.equals("Jul"))
mon= 07;
else if(Month.equals("Aug"))
mon = 08;
else if(Month.equals("Sep"))
mon = 09;
else if(Month.equals("Oct"))
mon=10;
else if(Month.equals("Nov"))
mon=11;
else if(Month.equals("Dec"))
mon=12;
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
When you prefix an integer with zero(0) it becomes an octal literal. Octals have a range from 0 - 7. Hence the error.
Ganesh Kumar
Ranch Hand

Joined: Jul 02, 2007
Posts: 113
Thank you Anupam!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in the code
 
Similar Threads
Finding number of days in a month confusion
dates and times as integers in a query string
Need Servlets 4a Help
Creating array of objects from user input and saving to a file
Analizing Dates for Calculation